From 58a47386a711746d17c5c66ac897a53f7a4aad4b Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 13 Oct 2020 07:02:26 +0800 Subject: +samurai & ninja animations --- Assets/Scripts/Test/RootConstainTest.cs | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Assets/Scripts/Test/RootConstainTest.cs (limited to 'Assets/Scripts/Test/RootConstainTest.cs') diff --git a/Assets/Scripts/Test/RootConstainTest.cs b/Assets/Scripts/Test/RootConstainTest.cs new file mode 100644 index 00000000..43c22b67 --- /dev/null +++ b/Assets/Scripts/Test/RootConstainTest.cs @@ -0,0 +1,35 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class RootConstainTest : MonoBehaviour +{ + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } + + private void OnAnimatorMove() + { + Animator animator = GetComponent(); + + // 约束z=0 + if (animator) + { + //animator.ApplyBuiltinRootMotion(); + transform.position += new Vector3(animator.deltaPosition.x, animator.deltaPosition.y, 0); + transform.forward = animator.deltaRotation * transform.forward; + Vector3 euler = animator.deltaRotation.ToEuler(); + euler.x = euler.z = euler.y = 0; + transform.rotation *= Quaternion.Euler(euler); + } + } + +} -- cgit v1.1-26-g67d0