控制物理是否会改变物体的旋转。
如果 freezeRotation 已启用,则物理模拟不会修改旋转。这对于创建第一人称射击游戏很有用,因为玩家需要使用鼠标完全控制旋转。其他资源:Rigidbody.constraints.
using UnityEngine;
public class Example : MonoBehaviour { Rigidbody m_Rigidbody;
private void Start() { //Fetch the Rigidbody from the GameObject with this script attached m_Rigidbody = GetComponent<Rigidbody>(); //Stop the Rigidbody from rotating m_Rigidbody.freezeRotation = true; } }