当前位置: 首页>>代码示例>>C#>>正文


C# Rigidbody2D.MovePosition方法代码示例

本文整理汇总了C#中UnityEngine.Rigidbody2D.MovePosition方法的典型用法代码示例。如果您正苦于以下问题:C# Rigidbody2D.MovePosition方法的具体用法?C# Rigidbody2D.MovePosition怎么用?C# Rigidbody2D.MovePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Rigidbody2D的用法示例。


在下文中一共展示了Rigidbody2D.MovePosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AnimalLeave

 IEnumerator AnimalLeave(Rigidbody2D animalRB)
 {
     while (animalRB.gameObject) {
         animalRB.MovePosition(Vector3.down);
         yield return new WaitForSeconds(1);
     }
 }
开发者ID:tomleclercq,项目名称:KissYourTeacher15,代码行数:7,代码来源:Trap.cs

示例2: OnCollisionEnter2D

	void OnCollisionEnter2D(Collision2D col)
	{
		if(col.gameObject.CompareTag("Player"))
		{
			rb = col.gameObject.GetComponent<Rigidbody2D>();

			rb.MovePosition (new Vector2(rb.position.x + teleportX, rb.position.y + teleportY));
		}
	}
开发者ID:jaraki,项目名称:VGDC-Winter-Game-Jam-Group-10,代码行数:9,代码来源:Teleport.cs

示例3: GrabGoat

	//--------------------------------------------------------------------------------
	#region Private Methods
	
	void GrabGoat(Rigidbody2D goat) {
		this.goat = goat;
		Debug.Log("Got the goat!");
		goat.isKinematic = true;
		goat.MovePosition(transform.position);
		goat.GetComponent<Collider2D>().enabled = false;
		onGoatGrabbed.Invoke();
		CharController player = GetComponentInParent<CharController>();
		Goat.instance.lastCarry = player.playerNum;
		Alter.instance.CancelWin();
	}
开发者ID:lancetipton04,项目名称:VG,代码行数:14,代码来源:GoatGrabber.cs

示例4: Move

    //public void Move(Vector2 movement_vector, Animator anim, Rigidbody2D rbody)
    //{
    //    if (movement_vector != Vector2.zero)
    //    {
    //        anim.SetBool("isWalking", true);
    //        anim.SetFloat("input_x", movement_vector.x);
    //        anim.SetFloat("input_y", movement_vector.y);
    //    }
    //    else
    //    {
    //        anim.SetBool("isWalking", false);
    //    }
    //    rbody.MovePosition(rbody.position + movement_vector * Time.deltaTime);
    //}
    public void Move(Vector2 movement_vector, Animator anim, Rigidbody2D rbody, float speed)
    {
        if (movement_vector != Vector2.zero)
        {
            anim.SetBool("isWalking", true);
            anim.SetFloat("input_x", movement_vector.x);
            anim.SetFloat("input_y", movement_vector.y);
        }
        else
        {
            anim.SetBool("isWalking", false);
        }

        rbody.MovePosition(rbody.position + movement_vector * speed * Time.deltaTime);
    }
开发者ID:RubenVO,项目名称:Dank-Rpg,代码行数:29,代码来源:Character.cs

示例5: Move

    public void Move(Transform enemyTransform, Transform playerTransform, Rigidbody2D rb, float minDistance, float speed)
    {
        float distance = (enemyTransform.position - playerTransform.position).magnitude;

        if (distance > minDistance)
        {
            Vector3 positionn = enemyTransform.position;
            Vector3 velocity = new Vector3 (0, speed * Time.fixedDeltaTime, 0);
            positionn += enemyTransform.rotation * velocity;

            rb.MovePosition (positionn);
        }
        else
        {
            rb.velocity = Vector2.zero;
        }
    }
开发者ID:frezzwar,项目名称:TestTSS,代码行数:17,代码来源:EmemyBehavior.cs

示例6: Start

 void Start()
 {
     sprite = (GameObject)transform.FindChild("Sprite").gameObject;
     if (hasHat) {
         animator.SetBool("HasHat", true);
         sprite.transform.Translate(new Vector3(0.11f, 0.16f, 0));
     }
     currentHealth = maxHealth;
     rigid = gameObject.GetComponent<Rigidbody2D>();
     if (isRunner) {
         speed = (Vector3.left / 200f);
     } else {
         speed = (Vector3.left / 500f);
     }
     rigid.MovePosition (transform.position + speed);
     if (Random.Range (0, 2) == 0) {
         audios[3].PlayOneShot(audios[3].clip);
     } else {
         audios[4].PlayOneShot(audios[4].clip);
     }
 }
开发者ID:5thFloorGames,项目名称:SpvtW,代码行数:21,代码来源:CatMove.cs


注:本文中的UnityEngine.Rigidbody2D.MovePosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。