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

Generic Root Motion over-rotation?

Discussion in 'Animation' started by GilesDMiddleton, Nov 12, 2016.

  1. GilesDMiddleton

    GilesDMiddleton

    Joined:
    Aug 12, 2015
    Posts:
    91
    I've spent two days trying to get this to work.
    I've developed a 90 degree turn left animation (from idle->turn 90->walk or idle), and during playback in unity, I've noticed that the root motion doubles up the animation (180' turn). This manifests in the game too. I've tried to halve the rotation of the root motion bone but this has other undesirable artefacts and feels wrong. As you can see the dog snaps back to where the root motion is really pointing.


    I need the dog to be facing whatever angle the animation exits at (it may exit early if the player releases the turn key).

    Maybe I'm doing this wrong, and will regret a 90degree animation? I mean, it will look a bit weird if you keep turning with 90 degree twists; but it frustrates me when things don't behave as I'd expect them to be; so trying to understand how to make things work.

    But what I can't understand is how to make this transition properly (e.g. my turn finishes at 90 degrees, and the dog continues walking). The blue marker for root motion confirms the root motion is correct. Is it because the root motion object is a bone in the armature? should it be a standalone object? (It's not actually connected to other bones, so not sure what the hell's going on).


    I tried making the root motion only do a 45degree turn but that then introduces worse problems.

    Note - if i get rid of the root motion bone's movement, the dog does the proper 90 degree animation, but then snaps back to the original direction before the animation plays.
    OverrotationDaisy.gif rigged90left.gif
     
  2. GilesDMiddleton

    GilesDMiddleton

    Joined:
    Aug 12, 2015
    Posts:
    91
    Ideally I'd like to solve this just with Root motion / config, but I've also been trying (failing) to do this via code.

    E.g. when the user lifts off the turn key, I set the transform of the main parent game object to the direction of one of the main back bones.

    However, these bones are rotated slightly and not the same orientation. Is there some clever maths to get the difference between orientations, then at the end of the animation, apply the delta back to the parent transform?
    I found this post, but it's only half the equation. http://answers.unity3d.com/questions/35541/problem-finding-relative-rotation-from-one-quatern.html
     
  3. GilesDMiddleton

    GilesDMiddleton

    Joined:
    Aug 12, 2015
    Posts:
    91
    OK - I think I may have a lead - and maybe some of you can easily answer these questions with "of course, you noob!".

    My root motion bone is NOT the root of the armature (e.g. it's not the top-most parent) I think that's causing the double rotation. It's currently just another disconnected bone in the armature.

    However, I fear that would make animation much harder - what to do with feet that MUST stay in place - e.g. where weight is on the paw, and not slide. I'll have to hack them back as the body rotates. Also not sure how I can make the animation look nice with the spine movement.

    Does that sound like the likely cause?

    Many thanks.
     
  4. JosephHK

    JosephHK

    Joined:
    Jan 28, 2015
    Posts:
    40
    Last edited: Nov 16, 2016
  5. GilesDMiddleton

    GilesDMiddleton

    Joined:
    Aug 12, 2015
    Posts:
    91
    Hi Joseph,

    Yes, I did read the documentation, about 400 times! Including the more complex section with root motion and orientations, but it's super confusing, with no visual explanation of how to setup a generic rig that contains a rotating motion and a rotating animation (nor how the structure of the rig/model should be). Lots of help / documentation focuses on humanoids and forward motion.

    I tried configuring as you said, and the most interesting thing is that all the options for rotation/position get removed when I set the "Motion"->"Root Motion" bone to anything other than "None". The above animation only worked when Rig->Root Motion was set to my rotation/motion bone.

    I'll strip this back to basics and repeat the process on a cube and see if I can recreate the problem without a large model. Good old cubie.
     
  6. JosephHK

    JosephHK

    Joined:
    Jan 28, 2015
    Posts:
    40
    Yes, if you assign something to the "Root Motion Node", the options for generating root motion will not be available.
    But what's the outcome if you configure as I said?

    Actually, this configuration does work for me although I am not sure whether this is what you want to achieve.

    Animation in blender



    Default import setting: Generic, No Root Node, No Root Motion Node
    http://imgur.com/CHcekNN



    Assign root bone to Root Node


    http://imgur.com/HHr4QFL


    Assign the bone which defines the root motion to Root Motion Node


     
    Last edited: Nov 17, 2016
    tokar_dev likes this.
  7. JosephHK

    JosephHK

    Joined:
    Jan 28, 2015
    Posts:
    40
    It seems that there is a bug if the root is stationary for generic type animation.

    The workaround that I figure out is to convert the Animation Type to None and then covert it back to Generic.

     
    Last edited: Nov 17, 2016
    dyupa and GilesDMiddleton like this.
  8. GilesDMiddleton

    GilesDMiddleton

    Joined:
    Aug 12, 2015
    Posts:
    91
    @JosephHK First of all, thank you for taking the time to make a video and highlight that bug. That really helped clear things up. You should get a thousand likes ;-)

    I used your video to re-assess my entire armature and bone structure.
    I restructured my bones, so all animating bones existed under one topmost bone, and the root motion bone was a also a disconnected child. I then had to fix rotation issues (as I've got unwanted roll and mixed axis alignments (grr)), my structure is still a little messy, but following your example IT WORKED. It needs tweaking a little but it's no longer DOUBLY rotated.

    I'm not 100% sure that the generic rig bug exists for me, I did follow your lead and flip from generic-none-generic so maybe I didn't get the chance to prove that. Do you know if Unity is aware of the bug?

    I've also noticed that things like the root motion bone needs an object in blender to be attached to, or it doesn't appear in unity, so I've added a fake axis object that sets itself as a parent to the root motion.

    Anyway, here's the current result! Many thanks.
    Screen Shot 2016-11-19 at 13.12.37.png YESYESYESLORES.gif
     
    JosephHK likes this.