Search Unity

Animation ignores Root Motion

Discussion in 'Animation' started by Cactus_on_Fire, Apr 10, 2016.

  1. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Hello.

    I have an animation prepared in Maya with a static locator to be used as root motion. After I import the animation and set it to Humanoid, I tell the animation to use this reference point as the animations Root motion and I select "bake into pose". The root motion gets stabilized in the animation but the feet keeps moving as if it's centering the body even though the feet shouldn't move at all.

    How can I fix this ?
     
  2. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
  3. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    A video could help.
    Sounds like the feet are not staying in place where the root node is located?

    Have you checked/unchecked under animation clips 'bake into pose' on rotation and position clip ranges?
     
  4. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Yep. Baking into the pose doesn't help really.
    I only get this problem with humanoid though, legacy root motion doesn't move around. But I can't use legacy with the animator so I need humanoid.
     
  5. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Can you explain your workflow a little more? and provide a video of the problem in Unity?

    In Maya are you animating by moving the original root node of the character in space, then parenting the root node to a "static locator" mentioned above and exporting with this static locator?

    Alternately in the original post it sounds like you might be animating the character inplace with the static locator already set as the root of the hierarchy, then in Unity the feet are doing something not right.
    Also "root motion gets stabilized" doesn't compute how I'd expect an animation with root motion to act.

    I'm just not understanding completely -
    Better explanation of the entire process is required to assist further, and if you want to have root motion for the character or not.
     
  6. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Well the workflow is like this :

    I use the default humanIK skeleton system in Maya which automatically creates a humanoid compatible bone hierarchy.
    I bake every frame of the animation and export the whole animation out with all the parts that appear in Maya as FBX.
    Then I import the FBX animation into Unity and choose humanoid.
    I configure the bones, get it into T-pose and make sure they all appear green, which automatically does that.
    Then I use the following options for the animation import settings :

    Loop Time
    Root Transform Rotation : Original
    Root Transform Position (Y) : Original
    Root Transform Position (X,Z) : Original

    And when I do that, the animation pulls the hips to the ground level and moves the entire body based on something like the average mass rather than a static location.

     
  7. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    What does this refer to? Where is the static locator and what/how is it involved with the character rig - you mentioned in the original post, but didn't mention in the second post?
    Did you input the -0.37 Y position offset?

    Your original post sounds like you are adding a master non-moving node that the root character bone is parented to, then using this master node as the root node in Unity.
     
  8. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    I don't pick anything in the import settings. There is a static locator getting imported from Maya as an empty game object named "Character1_ReferenceShape" in the FBX, but it's not a bone or anything so I can't use that as the static locator in the Root Motion Node in the animation tab.
    I tried using feet as the animations XY position since it doesn't move so I entered -0.37 in the offset to level the feet to the ground. But since the animation has the character leaning forward and pressing some buttons, the center of mass changes and it moves the whole body quite visibly, even though none of the characters shift their positions like that in the Maya animation or the FBX animations.

    Should I do something in Maya before exporting so I can use that as a static point ? Or is there a fix in Unity so the animation works properly as it appears in Maya ?
     
  9. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    I'm a Max artist so - help milage may vary greatly
    When I export from Max I select the mesh and the bones - nothing else - no IK controls, or random objects that are used to animate, no helper objects or nulls unless they are part of the rig hierarchy. (Animation controls are not part of the hierarchy)
    I then click "export selected" which only exports the objects I have selected in the scene.
    When the character comes into Unity everything just works as expected.

    I don't know if Maya has an export selected option - if it does try that and set up the character from scratch.
    You may also consider checking IK when you have selected root motion bake into pose.

    Seems there is something not quite right in the setup.
    Hope you solve the problem Cactus.
     
  10. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Also forgot to mention -
    After exporting from Max I always test the fbx file - importing it back into Max. Usually any mistakes will show up when the fbx file is imported back into the authoring tool.
    I don't think this will show anything on your issue - I believe the problem is in Unity - but can't hurt to test it.

    Just to clarify - the animations that are messing up - this is on a simple character with a simple 2 state - state machine and simple animation controller?
    No complex mecanim statemachine with a complex animation controller scripted with a multi-component character collider?
    Just trying to see where in the process you are noticing this animation issue.
     
  11. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Oh yeah I tried importing the FBXs back to Maya to check if they had issues, but they were working perfectly.

    It's using an animation tree but even on single animations it shifts the body rather than making it static.

    But the wierd thing is that the animation works fine when I use legacy. It doesn't shift or cause problems or anything. It only shifts the body when it uses humanoid.

     
  12. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Maybe just attempt a new project with only the character, simple 2 state - state machine and and character controller.

    What is the character collider setup? Do the character have a collider? Is the collider set - centered at the base of the feet instead of at the center of the character?
     
  13. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    No colliders. No rigid bodies. Only the animator component.

    It's either the humanoid or the animator causing this. By simple 2 state you mean an animator with just 2 transitioning animations ?
     
  14. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Yeah default idle state transition to walk animation transition back to default idle.
    In a completely new project with a new scene.
    If everything you have said up to this point about your rig and skin is correct - it is either something in the project causing unwanted results OR simething in the setup process that is causing unwanted results.
    If a new project results in the same problem - it is the setup.
    If the new project shows correct results - its the other project.
     
  15. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Anyone else had this problem ?
     
  16. TheAntiYou

    TheAntiYou

    Joined:
    Jun 23, 2016
    Posts:
    3
    I'm the same issue in Cinema4d. .fbx looks fine in legacy rig and in other other animation tools. I've even tried hiding a polygon in the model and bone hierarchy to shift the center of my object, then using that as root/root motion. No luck.
    I'm using a generic rig. All this happens in the animation preview window as well as in game.
    Edit: Removed IK handles and chains from Player avatar/model imported that. Then did the same with the animated rig baked all the frames/bones. Imported that. Same problem. Still looked fine in Legacy though. But I can't plug a legacy animation into the "motion" in the blend tree.
    Spent all day searching forums and playing with different Root and Rig settings.
     
    Last edited: Jun 23, 2016
  17. ogier

    ogier

    Joined:
    Nov 23, 2011
    Posts:
    222
    can you send a screenshot of your setup?

    Here is a setup that works perfectly if it can help you ...

    I had curious problems with wrong setting with the capsule collider (but you are saying not having one) ...
    I also think it is better to have no influences bone instead of null objects in the hierarchy
    (sreen01 in Cinema4D)

    Screen Shot 06-25-16 at 01.21 PM.PNG Screen Shot 06-25-16 at 01.32 PM.PNG
     
  18. TheAntiYou

    TheAntiYou

    Joined:
    Jun 23, 2016
    Posts:
    3



    Real close to your hierarchy. I have removed and baked the IK controllers/Goals before export.
    I even built a new Rig and weight and animations. Still the same problem with no hip motion. Yes, tried no Root motion node, and everything in between.
    As for the Animator and collider. I'm using a 2d box. However even in a new project and the animation preview the hip/root won't animate correctly. Im using Unity 5.3.5
    Considering the original poster is using Maya, i'm still at a loss.
    I've since moved onto Unreal4. ThoughI'll stick around to see if this problem is figured out. It's an old one and I've seen several questions about hip motion issues (hell, even tried renaming away from "hip"). with no definitive answer.
     
    Last edited: Jun 26, 2016
  19. Animiri

    Animiri

    Joined:
    Jul 1, 2016
    Posts:
    3
    Well, I´m struggling with the very same problems for almost a week now. I tried every possible hirachy, changed scalings of rigs and export units (like multiplying the rig by 100 and by 10), but the hip always turns out to be stuck in the floor in the end. I´m desperate guys.

    I´m using Unity 5.3.4p2
     
    Last edited: Jul 1, 2016
  20. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    It seems this is a very common problem with the animator component. Can't a moderator weight in and tell us whats wrong ?
     
  21. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Uhh, ok I just imported the default mecanim fbx to Maya and this is what I saw. The entire body seems to be parented to a bone thats at the top of the hierarchy and holds the hips as well as the rest which is located at (0,0,0) point.

    I really hope this isn't how they're solving the shifting problem.

     
  22. Animiri

    Animiri

    Joined:
    Jul 1, 2016
    Posts:
    3
    Why is my last post where I described how I solved this gone now? Was it so wrong that instead of giving me a better answer or correction it was worth deleting without any further comment? What the hell?
     
  23. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Are you sure it wasn't a server issue or something ? That happened to me once when they were having server maintnence and some of my comments didn't register. If it's not, I don't know if admins intentionally delete the community posts.

    Do you mind posting it again ?
     
  24. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Maybe you posted when they downgraded the forum for a week to that other version. Those posts are still on - that other forum.
     
  25. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    I don't mind looking at your rig and figuring out what's wrong.

    Please file a bug with a small project that contains your character and post the bug number here, I'll look at it.

    This way, you don't need to share your models and such with the forums, and I can fiddle around with it and work out what's wrong.

    Otherwise, it's pretty hard to diagnose in vacuum
     
    theANMATOR2b likes this.
  26. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Hey thanks man. We're working on another project now but I'll post that issue soon.
     
  27. Animiri

    Animiri

    Joined:
    Jul 1, 2016
    Posts:
    3
    Hey there Cactus!
    Yeah, maybe that´s what happend to my post. :/ Any ways! In the meantime I found even better solutions to the problem!
    Well look, this is the blog article of one of the programmers of the humanoid system. => http://blogs.unity3d.com/jp/2014/05/26/mecanim-humanoids/ It would be nice, if Unity would use his article and add it to the documentation or at least use the main informations which are missing.

    What I've done now is to follow all those rules described in the article to create the rig and then when it was ready to export, I kept the hirachy like this (deleting controls and constraints, just with the joints left):
    - joint_group - hips_joint
    - mesh (no mesh grp, just the mesh lying atop the hirachy with joint_group)

    Then the most important thing to get the scaling right for the root motion is to have the maya file settings set to meters and to change the export scale settings when exporting to centimeters!!!!

    (I think the scaling was my problem: Unity 5 thought, that my character was only 2 cm tall, thats why the calculations went wrong when applying the Root Motion to the character. Ergo, the hip gets liftet only 1 cm up high instead of 1 meter and seems to be stuck in the floor because of this. Maybe this has to do with the fact that in Max 100% scaling is 1 and in Maya 100% scaling is 100 :confused: I dont know)

    So, now if you want to export animations, bake the animation on the joints in Maya and export them the same way you exported the rig.
     
    Last edited: Aug 2, 2016
    theANMATOR2b likes this.