Search Unity

Root motion baking and playback

Discussion in 'Animation' started by FrontBackItaly, Aug 2, 2020.

  1. FrontBackItaly

    FrontBackItaly

    Joined:
    Aug 1, 2013
    Posts:
    8
    Hi everybody, I need some help on solving a problem which I haven't the faintest idea on how to solve it. Basically, I'm implementing my own GPU animation instancing and I'm stuck at implementing root motion. I can already sample an animation with no effort, but I don't know exactly what to save that makes most sense (absolute TRS? relative?) and then again, I don't know how to apply it correctly given the current animation state (I have 4 animations per layer with their own weights, with 4 layers with their weights aswell).
    With all the methods I tried, I only got exaggerated root motion or considerable drifting. (I made a capture to explain what happens, the highlighted object is the one controlled by Mecanim as a reference, the other one is handled by my system https://drive.google.com/file/d/1LZBT2H20NnTDFTiX7xxZYEz5Rd30Mc7O/view?usp=sharing)

    At the moment I save the absolute TRS of each animation frame (I sample everything at 60 FPS), then at runtime I compute the TRS at the previous state, the one at the current state, then apply the delta to the transform, and if necessary I add an offset equal to the TRS of the last frame in the animation to handle looping animations. Do you guys have any ideas?
    Hope I explained everything clearly enough. I'm Using Unity 2019.4.1f1.