diff options
author | chai <chaifix@163.com> | 2021-09-02 09:59:31 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-09-02 09:59:31 +0800 |
commit | 3ad68338dff5229d3fd8ec9f3ee994d7e37fb0ed (patch) | |
tree | b5fbf74148147019f75dd4c078fd76f4804330ec /Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs | |
parent | f7e60ab9a52e557aa2250477d018b2768bccc028 (diff) |
*override rootmotion
Diffstat (limited to 'Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs')
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs | 28 |
1 files changed, 18 insertions, 10 deletions
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() |