实测过确实可行,注意如果没有刚体组件,实现方式会不一样

public class TestSMB : StateMachineBehaviour
{
public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Vector3 velocity = animator.deltaPosition / Time.deltaTime; var rigidbody = animator.GetComponent<Rigidbody>(); if (rigidbody != null)
{
velocity.y = rigidbody.velocity.y; rigidbody.velocity = velocity;
}
}
}
04-16 12:44