Version: 2021.1

MonoBehaviour.OnAnimatorMove()

切换到手册

描述

用于处理动画移动以修改根运动的回调。

该回调在处理完状态机和动画后 (但在 OnAnimatorIK 之前)的每个帧中调用。

另请参阅:根运动

using UnityEngine;
using System.Collections;

public class Example : MonoBehaviour { void OnAnimatorMove() { Animator animator = GetComponent<Animator>();

if (animator) { Vector3 newPosition = transform.position; newPosition.x += animator.GetFloat("Runspeed") * Time.deltaTime; transform.position = newPosition; } } }