本文整理汇总了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);
}
}
示例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));
}
}
示例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();
}
示例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);
}
示例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;
}
}
示例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);
}
}