根骨骼运动原始实现代码

Posted HONT blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了根骨骼运动原始实现代码相关的知识,希望对你有一定的参考价值。

实测过确实可行

 

技术分享
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;
        }
    }
}
View Code

 

以上是关于根骨骼运动原始实现代码的主要内容,如果未能解决你的问题,请参考以下文章