Version: 2017.2

Rigidbody.angularVelocity

切换到手册
public Vector3 angularVelocity ;

描述

刚体的角速度矢量(以弧度/秒为单位)。

在大多数情况下,您不应该直接修改它,因为这可能导致行为失真。

// Change the material depending on the speed of rotation
using UnityEngine;

public class ExampleClass : MonoBehaviour { public Material fastWheelMaterial; public Material slowWheelMaterial; public Rigidbody rb; public MeshRenderer rend;

void Start() { rb = GetComponent<Rigidbody>(); rend = GetComponent<MeshRenderer>(); }

void Update() { if (rb.angularVelocity.magnitude < 5) rend.sharedMaterial = slowWheelMaterial; else rend.sharedMaterial = fastWheelMaterial; } }