From 97b64a629a95980d9a2f6c9e37b4cb44acf33a59 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 26 Oct 2020 21:33:09 +0800 Subject: =?UTF-8?q?*=E8=B7=B3=E8=B7=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Test/SaionjiScript.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Assets/Scripts/Test/SaionjiScript.cs') diff --git a/Assets/Scripts/Test/SaionjiScript.cs b/Assets/Scripts/Test/SaionjiScript.cs index 7fac11f3..03dfbf8d 100644 --- a/Assets/Scripts/Test/SaionjiScript.cs +++ b/Assets/Scripts/Test/SaionjiScript.cs @@ -49,11 +49,20 @@ public partial class SaionjiScript : MonoBehaviour, IInteractable void OnAnimatorMove() { Animator animator = GetComponent(); - - // animator.deltaPosition和animator.deltaRotation是animator做的root motion后的结果 - // 在后面做一个硬性约束z=0,将角色限制在z=0平面上 - if (animator) + if (animator == null) + return; + + AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0); + + if(stateInfo.IsTag("IgnoreRootMotion")) + { + // ignore root motion + Debug.Log("ignore root motion "); + } + else { + // animator.deltaPosition和animator.deltaRotation是animator做的root motion后的结果 + // 在后面做一个硬性约束z=0,将角色限制在z=0平面上 Vector3 position = transform.position; position.x += animator.deltaPosition.x; position.y += animator.deltaPosition.y; -- cgit v1.1-26-g67d0