position | The new position for the Rigidbody object. |
Rigidbodyオブジェクトを指定する位置へ移動します
Changing the position of a Rigidbody object by setting its transform.position value will cause it to "teleport" directly to the new position (ie, it doesn't move through any intermediate positions along the way). Any other Rigidbodies lying between the old position and the new one will be unaffected by the movement. Also, any colliders at the target position will react immediately with the moved rigidbody on the next update. If you use MovePosition instead, the physics engine will trace a straight line path between the object's old position and the new one and behave as though it rapidly moved along that path between updates. Objects lying along the path will be pushed aside if necessary. This often gives a more acceptable result than changing transform.position. However, if the movements are small and frequent then the two techniques behave very similarly.
private var speed : Vector3 = Vector3 (3, 0, 0); function FixedUpdate () { rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { private Vector3 speed = new Vector3(3, 0, 0); void FixedUpdate() { rigidbody.MovePosition(rigidbody.position + speed * Time.deltaTime); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): private speed as Vector3 = Vector3(3, 0, 0) def FixedUpdate() as void: rigidbody.MovePosition((rigidbody.position + (speed * Time.deltaTime)))