Root motion accuracy issue

I have a simple enemy prototype that has an animation controller consisting of two states - both have root motion and both downloaded from Mixamo

  • walking forward (default)
  • 180 degrees turn (activates with trigger named “turn”).

In code/script I make two boxcasts to see if there’s a wall or a hole in the ground ahead and set the “turn” trigger if there are any obstacles ahead.

At first everything seemed to work fine, but over time I realized that the turn animation starts to drift off. The turn ends at (for example) 179 degrees instead of 180 and this difference gets bigger and bigger with every turn and finally character starts to walk diagonally.

I tried many different things.

It’s not related to transitions - because I made the transition from turn to walking have 1 exit time with 0 transition/blend time.

Changing “offset” in animation import wizard didn’t help - as well as turning off animation compression.

I did some trial-and-error testing and came up with hacky solution. When I change “update mode” on this character’s animation controller to “Animate Physics” (instead of default “normal” mode), the rotations are always perfect 180 degrees turns and character never starts to walk diagonally.

My question is - is there any better, less “hacky” solution than changing the update mode? If not - can someone explain to me why is this necessary? I don’t even have rigid body on this character.

Did you ever resolve this to an accurate solution? I'm having the same problem translating an object using Root Motion, I want it to move for example 1 unit but it always seems to move some inaccurate amount near 1 unit such as 1.0389 or the like and each time it stacks causing it to be way off really quickly.

1 Answer

1

I had the same problem, I couldn’t solve it.

Using Animate physics did not fix it for me. It makes it better because it uses the physics timestep and that doesn’t change based on the framerate, at least that’s why I think it helps.
However, I think the issue here is the humanoid rig, retargeting animations to different rigs must have inaccuracies with the bones positioning.

The animation would be accurate if it was generic. But I’m guessing root motion doesn’t work if you need it to end at a super exact number.

You could use OnAnimatorMove in your script to handle root motion manually, there’s a bunch of resources about that. But for my case that didn’t help and I created a seperate system because in my game i need the positions to be very accurate.