diff options
Diffstat (limited to 'Assets/Scripts/Avatar/EnforceZCoord.cs')
-rw-r--r-- | Assets/Scripts/Avatar/EnforceZCoord.cs | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/Assets/Scripts/Avatar/EnforceZCoord.cs b/Assets/Scripts/Avatar/EnforceZCoord.cs deleted file mode 100644 index 2adcd4d6..00000000 --- a/Assets/Scripts/Avatar/EnforceZCoord.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class EnforceZCoord : MonoBehaviour -{ - private void Start()
- {
-
- }
-
- void OnAnimatorMove() - { - Animator animator = GetComponent<Animator>(); - if (animator == null) - return; - - AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(0); - - if (stateInfo.IsTag("IgnoreRootMotion")) - { - // ignore root motion - //Debug.Log("ignore root motion "); - } - else if (stateInfo.IsTag("IgnoreRootMotionY")) - { - Vector3 position = transform.position; - position.x += animator.deltaPosition.x; - transform.position = position; - - transform.rotation *= animator.deltaRotation; - } - 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; - transform.position = position; - - // animation clip导入设置旋转一般上设置为baked inpose,不需要手动限制 - transform.rotation *= animator.deltaRotation; - } - } -} |