实测过确实可行,注意如果没有刚体组件,实现方式会不一样
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
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; } } }