diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-22 13:23:04 +0800 |
|---|---|---|
| committer | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-22 13:24:30 +0800 |
| commit | 905b0c36301e96feabac6cd3e2a51252b075ef66 (patch) | |
| tree | b7c4a738cc5f85a75ed6a1cb70574a6d734d46d3 /Assets/Scripts | |
| parent | 6903a64ed15bf6046bddd98a4bc095b1ea5844ee (diff) | |
改了个RootMotion的代码,并且我要谴责罗师傅的单例时机不对
Diffstat (limited to 'Assets/Scripts')
| -rw-r--r-- | Assets/Scripts/AnimatorHandler.cs | 6 | ||||
| -rw-r--r-- | Assets/Scripts/InputHandler.cs | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/Assets/Scripts/AnimatorHandler.cs b/Assets/Scripts/AnimatorHandler.cs index deae0ac..f285dca 100644 --- a/Assets/Scripts/AnimatorHandler.cs +++ b/Assets/Scripts/AnimatorHandler.cs @@ -11,6 +11,9 @@ namespace DS /// </summary> public class AnimatorHandler : MonoBehaviour { + [Header("绑定")] + public Transform rootMotionRotation; // 将他妈的模型旋转绑定到 RootMotion + [Header("组件引用")] public PlayerLocomotion playerLocomotion; // 玩家移动控制器引用,用于传递根运动数据 public Animator animator; // 动画器组件引用 @@ -139,7 +142,7 @@ namespace DS { // 获取当前帧的根运动位移向量 var rootMotion = GetRootMotion(); - + // 输出调试日志,用于查看根运动数据 Debug.Log(rootMotion); @@ -174,6 +177,7 @@ namespace DS // 将 animator.velocity(动画驱动的速度向量)投影到法线定义的平面上 // Vector3.ProjectOnPlane 会去除向量中沿法线方向的分量 // 这样只保留水平方向的位移,避免 Y 轴上的微小波动影响角色位置 + // return Vector3.ProjectOnPlane(animator.velocity, normalVector); return Vector3.ProjectOnPlane(animator.velocity, normalVector); } } diff --git a/Assets/Scripts/InputHandler.cs b/Assets/Scripts/InputHandler.cs index 4d0bba1..6da34f0 100644 --- a/Assets/Scripts/InputHandler.cs +++ b/Assets/Scripts/InputHandler.cs @@ -37,7 +37,7 @@ namespace DS // ===== Unity 生命周期方法 ===== - private void Awake() + private void Start() { // 获取相机处理器的单例引用,用于在 FixedUpdate 中驱动相机跟随与旋转 _cameraHandler = CameraHandler.singleton; |
