From 98fc0175e3f614153fe201c9fcea693611fb4eed Mon Sep 17 00:00:00 2001 From: Weicao-CatilGrass <1992414357@qq.com> Date: Fri, 22 May 2026 12:24:34 +0800 Subject: 改了个抽象代码 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/AnimatorHandler.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Assets/Scripts') 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); } } -- cgit