diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-22 12:24:34 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-22 12:24:34 +0800 |
| commit | 98fc0175e3f614153fe201c9fcea693611fb4eed (patch) | |
| tree | 7264d72fdf7d3277d3c061d80352b56c06fe2280 /Assets/Scripts | |
| parent | 9045525044dd1ab38a559598bea54858f4050c49 (diff) | |
改了个抽象代码
Diffstat (limited to 'Assets/Scripts')
| -rw-r--r-- | Assets/Scripts/AnimatorHandler.cs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Assets/Scripts/AnimatorHandler.cs b/Assets/Scripts/AnimatorHandler.cs index b71c573..df1f1f1 100644 --- a/Assets/Scripts/AnimatorHandler.cs +++ b/Assets/Scripts/AnimatorHandler.cs @@ -92,16 +92,21 @@ namespace DS private void OnAnimatorMove() { - Debug.Log(animator.velocity); - playerLocomotion.rootMotion = animator.velocity; + var rootMotion = GetRootMotion(); + Debug.Log(rootMotion); + playerLocomotion.rootMotion = rootMotion; } private void OnDrawGizmos() { + Gizmos.DrawLine(transform.position, transform.position + GetRootMotion() * 2f); + } + + private Vector3 GetRootMotion() + { // 我们先假定 地板永远是朝上的 var normalVector = Vector3.up; - Vector3 rootMotionProjected = Vector3.ProjectOnPlane(animator.velocity, normalVector); - Gizmos.DrawLine(transform.position, transform.position + rootMotionProjected * 2f); + return Vector3.ProjectOnPlane(animator.velocity, normalVector); } } |
