Filtering Root Motion Data

Is it possible to filter out XY root motion data so I am only giving the rotation to the transform?

I need to preserve the current rigidbody velocity, and ignore root motion XY.

Thanks

It seems in my development career that I always seem to find the answer to problems I have had immediately after posting to a forum…

Anyways… For any future people looking at this post with the same question. You need to manually set your root motion values as follows in the OnAnimatorMove lifecycle function:

private void OnAnimatorMove()
{
        animator.applyRootMotion = true; //Tell your animator to apply Root Motion
        transform.rotation = animator.rootRotation;  //Then this sets the rotation component of the transform from the root motion.
}

Its that easy.

I struggled with this for a long while because I didn’t realize OnAnimatorMove is there for you to manually set each part of root motion! By default when you override this lifecycle function, it doesnt apply ANY root motion, you have to tell it to do so, which makes it easy to set up one single component of the root motion.

Happy coding

2 Likes