Monday, December 5, 2022
HomeGame Developmentunity - What's ApplyBuiltinRootMotion and easy methods to use it?

unity – What’s ApplyBuiltinRootMotion and easy methods to use it?


When you’ve got a script in your gameObject that implements OnAnimatorMove(), then the foundation motions of any animations are ignored. That’s sadly not documented in OnAnimatorMove the place you’d count on it, however within the documentation of the Animator.applyRootMotion property:

Root movement is the impact the place an object’s whole mesh strikes away from its place to begin however that movement is created by the animation itself moderately than by altering the Rework place. Observe that applyRootMotion has no impact when the script implements a MonoBehaviour.OnAnimatorMove perform.

Nonetheless, generally you’ve got the case that you just need to use your personal root movement logic solely in some circumstances when you produce other circumstances the place you need to depart the foundation movement to the animation clip. In that case, you name animator.ApplyBuiltinRootMotion() inside OnAnimatorMove to revive the conventional habits. The code within the query is in fact moderately pointless. It takes over management of root movement by having an implementation of OnAnimatorMove, however then it palms root movement management proper again to the animation system by calling ApplyBuiltinRootMotion().However you might need code like this the place this methodology is barely executed when you’re not in a state the place you’ve got an personal root movement implementation:

 personal void OnAnimatorMove()
 {
     if (ourAnimationUsesCustomRootMotion == true) {
        // We're presently dealing with root movement manually
        remodel.place += ourRootMotionVector;
     } else {
        // We do not have customized root movement enabled proper now, so let's depart it to the animation system
        _animator.ApplyBuiltinRootMotion();
     }
 }

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments