public float moveLength ;

描述

该角色在撞到该碰撞体前行进的距离。

注意,这可能与您传递到 CharacterController.Move 的不同,因为初始运动矢量根据 CharacterController.stepOffset 被分解成一系列运动。

另请参阅:ControllerColliderHit.moveDirection

using UnityEngine;

public class ExampleClass : MonoBehaviour { void OnControllerColliderHit(ControllerColliderHit hit) { Debug.Log(hit.moveLength); } }