Search Unity

How to read Motion T and Motion Q

Discussion in 'Animation' started by pyjamaslug, Apr 18, 2019.

  1. pyjamaslug

    pyjamaslug

    Joined:
    Jul 5, 2017
    Posts:
    51
    Hi all, just getting started on some animation tasks and have a basic question. I imported a few animations from mixamo and want them to play in sequence using the animator controller. These clips have root motion defined in curves. I have created the graph and the animations play nicely in sequence but since the character motion is encoded in imported Motion T and Motion Q curves, it goes back to the origin at every transition. Naturally, I want each clip to start from the position the old one left off and the easiest way I can think of to do that is to sample the ending Motion T and Motion Q values from the curves and just apply them to the transform of the character.
    My problem is that I can't find a way to read those values from my script. Any pointers appreciated (or if I am just totally barking up the wrong lamppost, that input would also be appreciated)

    PjM
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    If you have Root Motion enabled on the Animator it should take care of it for you.

    You can't directly access the curves of a clip at runtime. To get the actual curves you would need to get them in the editor, and serialize them separately. But since you know you just want the position and rotation of a specific transform, you should just be able to grab those values from the transform without messing around with curves at all.
     
  3. pyjamaslug

    pyjamaslug

    Joined:
    Jul 5, 2017
    Posts:
    51
    That doesn't work. If you do that you get the applied root motion added to the motion from the curves. I am working on just looking at the hip transform X and Z components and applying those to the root transform at the appropriate moment. I saw elsewhere that this is what unity does under the hood so it should work. I''ll let you know how it goes (but I need to go and work out right now...)
     
  4. pyjamaslug

    pyjamaslug

    Joined:
    Jul 5, 2017
    Posts:
    51
    I now have a solution for this. I'm not sure if this was truly obscure or just a result of my inexperience. Anyway, follow these steps:

    - Download T-pose for the model you are working with.
    - Set the rig to humanoid and place the model in the hierarchy. There should be an animator component already added with the t-pose avatar referenced, if not, add it.
    - In the Animator component, apply root motion and set update mode to Animate Physics
    - Fix up the materials (different topic, you can do it later if you want)
    - Create an animator controller and add it to the animator component.
    - Go back to mixamo and apply a new animation to the model you are working with.
    - Download the FBX and import it into unity.
    - Change the rig to humanoid
    - On that Rig tab, change Avatar Definition to "Copy from other Avatar" then in the "Source" box that appears, reference the T-Pose avatar from the model you have loaded into the scene.
    - If you want it to loop time, set that in the animation tab
    - Drag the FBX containing the new animation into the animator controller.
    - If you add multiple animations that are not in-place, each one will start at the location the last one left off.