aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/AnimatorHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/AnimatorHandler.cs')
-rw-r--r--Assets/Scripts/AnimatorHandler.cs16
1 files changed, 16 insertions, 0 deletions
diff --git a/Assets/Scripts/AnimatorHandler.cs b/Assets/Scripts/AnimatorHandler.cs
index d95d12b..b71c573 100644
--- a/Assets/Scripts/AnimatorHandler.cs
+++ b/Assets/Scripts/AnimatorHandler.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -6,6 +7,7 @@ namespace DS
{
public class AnimatorHandler : MonoBehaviour
{
+ public PlayerLocomotion playerLocomotion;
public Animator animator;
private int _vertical;
private int _horizontal;
@@ -87,6 +89,20 @@ namespace DS
{
canRotate = false;
}
+
+ private void OnAnimatorMove()
+ {
+ Debug.Log(animator.velocity);
+ playerLocomotion.rootMotion = animator.velocity;
+ }
+
+ private void OnDrawGizmos()
+ {
+ // 我们先假定 地板永远是朝上的
+ var normalVector = Vector3.up;
+ Vector3 rootMotionProjected = Vector3.ProjectOnPlane(animator.velocity, normalVector);
+ Gizmos.DrawLine(transform.position, transform.position + rootMotionProjected * 2f);
+ }
}
}