public Rigidbody rigidbody ;

描述

被该控制器撞击的刚体。

如果我们没有接触刚体,而是接触了一个静态碰撞体,则为 null。

using UnityEngine;

public class Example : MonoBehaviour { // Activate the gravity of other object we touch void OnControllerColliderHit(ControllerColliderHit hit) { if (hit != null) { hit.rigidbody.useGravity = true; } } }