Version: 2020.2
public Quaternion rotation ;

描述

刚体的旋转。

使用 Rigidbody.rotation 以通过物理引擎获取和设置刚体的旋转。

使用 Rigidbody.rotation 更改刚体的旋转会在下一个物理模拟步骤后更新变换。这比使用 Transform.rotation 更新旋转要快,因为 Transform.rotation 将导致所有附加的碰撞体重新计算其相对于刚体的旋转,而 Rigidbody.rotation 会直接将值设置到物理系统。

如果需要连续旋转刚体,请改为使用 MoveRotationMoveRotation 会考虑插值问题。

__注意:__.rotation 使用世界空间。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Start() { GetComponent<Rigidbody>().rotation = Quaternion.identity; } }