用于处理动画移动以修改根运动的回调。
该回调在处理完状态机和动画后
(但在 OnAnimatorIK 之前)的每个帧中调用。
See Also: Root motion.
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { void OnAnimatorMove() { Animator animator = GetComponent<Animator>(); if (animator) { Vector3 newPosition = transform.position; newPosition.z += animator.GetFloat("Runspeed") * Time.deltaTime; transform.position = newPosition; } } }