From 3ad68338dff5229d3fd8ec9f3ee994d7e37fb0ed Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 2 Sep 2021 09:59:31 +0800 Subject: *override rootmotion --- .../Unit/Components/UnitAnimation/PCAnimation.cs | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs') diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs index 33bd4d4e..dbd4dd49 100644 --- a/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs +++ b/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs @@ -71,6 +71,8 @@ public class PCAnimation : UnitAnimation public bool applyRootMotion { get; set; }// 动态设置root motion public bool applyRootCurve { get; set; } // 程序生成的root motion + public bool updateAnimationAuto { get; private set; } // 自动更新动画 + public override void Initialize() { base.Initialize(); @@ -89,7 +91,9 @@ public class PCAnimation : UnitAnimation } applyRootMotion = true; - } + + updateAnimationAuto = true; + } public override void OnUpdate() { @@ -97,11 +101,8 @@ public class PCAnimation : UnitAnimation UpdateLayer(); UpdateAnimation(); - - if (applyRootMotion) - UpdateRootMotion(); - if (applyRootCurve) - UpdateRootCurve(); + UpdateRootMotion(); + UpdateRootCurve(); } void UpdateLayer() @@ -116,18 +117,25 @@ public class PCAnimation : UnitAnimation void UpdateAnimation() { - m_Animator.speed = 1; - m_Animator.Update(Time.deltaTime); - m_Animator.speed = 0; - } + if(updateAnimationAuto) + { + m_Animator.speed = 1; + m_Animator.Update(Time.deltaTime); + m_Animator.speed = 0; + } + } void UpdateRootMotion() { + if (!applyRootMotion) + return; m_Owner.unitRootMotion.UpdateRootMotion(); } void UpdateRootCurve() { + if (!applyRootCurve) + return; } public void AnimIdle() -- cgit v1.1-26-g67d0