當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。