summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Test/ArmorSoldierScript.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Test/ArmorSoldierScript.cs')
-rw-r--r--Assets/Scripts/Test/ArmorSoldierScript.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/Assets/Scripts/Test/ArmorSoldierScript.cs b/Assets/Scripts/Test/ArmorSoldierScript.cs
new file mode 100644
index 00000000..e4b051e1
--- /dev/null
+++ b/Assets/Scripts/Test/ArmorSoldierScript.cs
@@ -0,0 +1,37 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class ArmorSoldierScript : 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<Animator>();
+
+ // animator.deltaPosition和animator.deltaRotation是animator做的root motion后的结果
+ // 在后面做一个硬性约束z=0,将角色限制在z=0平面上
+ if (animator)
+ {
+ Vector3 position = transform.position;
+ position.x += animator.deltaPosition.x;
+ position.y += animator.deltaPosition.y;
+ transform.position = position;
+
+ // animation clip导入设置旋转一般上设置为baked inpose,不需要手动限制
+ transform.rotation *= animator.deltaRotation;
+ }
+ }
+
+}