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) { Vector3 position = transform.position; position.x += animator.deltaPosition.x; position.y += animator.deltaPosition.y; transform.position = position; transform.rotation *= animator.deltaRotation; //transform.forward = animator.deltaRotation * transform.forward; //Vector3 euler = animator.deltaRotation.ToEuler(); //euler.x = euler.z = euler.y = 0; //transform.rotation *= Quaternion.Euler(euler); } } }