RootMotion works by default with RichAi?


Almost 1 year ago when I started using A*, I had to setup some code in order for the RM to work with RichAi. Right now, I just do

        _aStarAi.isStopped = false;
        _aStarAi.destination = destination;

And enable RM in the animator component and it seems to work fine. This is the code I used to use before, can I get rid of it?

// Update method

        Vector3 nextPosition;
        Quaternion nextRotation;

        _aStarAi.MovementUpdate(Time.deltaTime, out nextPosition, out nextRotation);
        _aStarAi.FinalizeMovement(new Vector3(_animator.rootPosition.x, nextRotation.y, _animator.rootPosition.z), nextRotation);

For some reason the code above is not working with my new characters, they “jump” in the air.

EDIT: The “jump” is caused because my character’s position Y is negative… I also notice the speed of the walk animation is way too fast compared to when Im not using rich ai (just a character + animator), so I decreased the Max Speed from 1 to 0.5 and it seems to work better, I dont know why and how this will affect my other animations such as run… Do you have any ideas?


There is nothing new that takes root motion into account for the RichAI, so that previous code should still be required I think.

I note that you explicitly set the new y coordinate of the character to the y coordinate of the nextRotation quaternion. That makes absolutely no sense as they do not even represent the same coordinate system. Are you sure you didn’t mean to use nextPosition there instead?

What does the Max Speed value on the RichAi has to do with the speed of the animation, shouldnt it use the speed of the animation instead and not care about that value when RootMotion is eanbled? It was 1 by default but setting it to 0.01 gets me a similar movement to what the root motion walk animation produces without a RichAi component.

When it’s 1, it’s just too fast.


I you do not use your old code then both the RichAI and the root motion will move the character, so essentially the speed of the character will be the sum of the RichAI’s speed and the root motion speed. This is one of the reasons you should still use the original code.
I would recommend that you set the max speed of the RichAI to roughly the same speed as the root motion is moving it with to make the steering work best.

I am using my code and the Max Speed still affects the movement speed of the animation.
If the Max Speed is 0 then the agent wont even follow its path but follow a straight line. Currently 0.01 gives me best / realistic results with walk and run, but no idea why.

That’s likely some artefact of how you set the animation parameters. I would guess that you essentially tell mecanim in this case to move, but not in any particular direction, so it defaults to forward.

Well, it’s hard for me to say why unless I know what code you are using.