Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Root motion accuracy issue

Discussion in 'Animation' started by DKaras, Nov 7, 2021.

  1. DKaras

    DKaras

    Joined:
    Sep 5, 2015
    Posts:
    5
    I have a simple enemy prototype that has an animation controller consisting of two states - both have root motion and both animations are 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.