aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts')
-rw-r--r--Assets/Scripts/AnimatorHandler.cs13
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);
}
}