Rigidbody.MovePosition 移动位置

function MovePosition (position : Vector3) : void

Description描述

Moves the rigidbody to position.

移动刚体到position。

For kinematic rigidbodies it applies friction based on the motion of the rigidbody. This lets you simulate moving platforms with rigidbodies sitting on top of the elevator. If you want other rigidbodies to interact with the kinematic rigidbody you need to move it in the FixedUpdate function.

对于运动学刚体,它基于刚体的运动应用摩擦力。这个让你模拟刚体位于移动平台之上的情况。如果你想其他的刚体与运动学刚体交互,你需要在FixedUpdate函数中移动它。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	private Vector3 speed = new Vector3(3, 0, 0);
	void FixedUpdate() {
		rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime);
	}
}
private var speed : Vector3 = Vector3 (3, 0, 0);
function FixedUpdate () {
	rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime);
}
Page last updated: 2011-2-10