rot | 刚体的新旋转。 |
将刚体旋转到 /rotation/。
使用 Rigidbody.MoveRotation 旋转 Rigidbody,符合刚体的插值设置。
If Rigidbody interpolation is enabled on the Rigidbody, calling Rigidbody.MoveRotation will resulting in a smooth transition between the two positions in any intermediate frames rendered. This should be used if you want to continuously rotate a rigidbody in each FixedUpdate.
若要将刚体从一个旋转传送到另一个旋转,并且不渲染任何中间位置,请改为设置 Rigidbody.rotation。
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public Rigidbody rb; Vector3 newPos = new Vector3(10.0f, 0.0f, 3.0f); float speed = 1.0f;
void Start() { rb = GetComponent<Rigidbody>(); }
// fixedDeltaTime provides the same time that FilterUpdate() uses void FixedUpdate() { if (rb.position.x <= 1.0f) { Vector3 direction = (newPos - transform.position).normalized; rb.MovePosition(transform.position + direction * speed * Time.fixedDeltaTime); } } }
如果 isKinematic
设置为 false,则传送对象(而不是平滑过渡)。