From de78537f8edc6cb162ba58520956255f7e53769d Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 29 Aug 2021 12:54:37 +0800 Subject: =?UTF-8?q?*=E8=BD=B4=E5=90=91=E6=94=B9=E4=B8=BAxy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Unit/Component/UnitAnimation.cs | 35 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'Assets/Scripts/Unit/Component/UnitAnimation.cs') diff --git a/Assets/Scripts/Unit/Component/UnitAnimation.cs b/Assets/Scripts/Unit/Component/UnitAnimation.cs index a6a7f3eb..4532023d 100644 --- a/Assets/Scripts/Unit/Component/UnitAnimation.cs +++ b/Assets/Scripts/Unit/Component/UnitAnimation.cs @@ -286,6 +286,9 @@ public class UnitAnimation : UnitComponent public AnimatorLayerInfo[] layers { get { return m_LayerInfo; } } private readonly AnimatorLayerInfo[] m_LayerInfo = new AnimatorLayerInfo[(int)ELayer.Count]; + public bool applyRootMotion { get; set; }// 动态设置root motion + public bool applyRootCurve { get; set; } // 程序生成的root motion + public bool isInTransition { get @@ -309,6 +312,8 @@ public class UnitAnimation : UnitComponent { LogHelper.LogError("没有挂Animator组件"); } + + applyRootMotion = true; } public override void OnUpdate() @@ -317,8 +322,12 @@ public class UnitAnimation : UnitComponent UpdateLayer(); UpdateAnimation(); - UpdateRootMotion(); - } + + if(applyRootMotion) + UpdateRootMotion(); + if(applyRootCurve) + UpdateRootCurve(); + } void UpdateLayer() { @@ -342,7 +351,13 @@ public class UnitAnimation : UnitComponent m_Owner.unitRootMotion.UpdateRootMotion(); } - public void AnimIdle() + void UpdateRootCurve() + { + + } + + + public void AnimIdle() { #if ANIM_CROSS_FADE m_Animator.CrossFade("Idle", 0.2f, 0); @@ -394,7 +409,19 @@ public class UnitAnimation : UnitComponent #endif } - public void AnimLanding() + public void AnimAirDash() + { + if (layers[0].stateInfo.IsName("AirDash")) + { + m_Animator.Play("AirDash", 0, 0); + } + else + { + m_Animator.CrossFade("AirDash", 0.05f); + } + } + + public void AnimLanding() { #if ANIM_CROSS_FADE m_Animator.CrossFade("Landing", 0.05f); -- cgit v1.1-26-g67d0