Search Unity

Is there a way to simulate Root Motion using Animation Rigging package?

Discussion in 'Animation Rigging' started by Ratslayer, Apr 18, 2020.

  1. Ratslayer

    Ratslayer

    Joined:
    Feb 6, 2014
    Posts:
    37
    Hi. I've been using Animation Rigging package to do Full Body IK and it's been great so far. However, one thing I can't figure out is how to do Root Motion with it.

    I am using Unity Animation Window to animate a Humanoid Character but I don't use any of Unity's muscle system, I only key effector movements. It works fine, but I don't know how to change my character's position/rotation without it being reset at the end of the clip.

    Anyone has any ideas how to make that work?
     
  2. danUnity

    danUnity

    Joined:
    Apr 28, 2015
    Posts:
    229
    If you are using the Animator, you can disable Write Defaults in the animation state to make sure that if you go to another state that does not animate the root that you won't go to the beginning of the animation.

    Or maybe you could use Animator's Layer system with subsequent layers on additive mode and the root animation would be on the base layer?

    Not sure exactly what you want to do though with your animation so hard to help
     
  3. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    149
    Hello.
    Hey. Really interested in what you're doing, and how you control a rig with code, without a state machine.

    Or if you wanted to use state machine there a couple of videos might help you. But either way, I could do with some pointers. here are videos technique danUnity is suggesting:

    https://drive.google.com/file/d/1JiDcLZlc9mk-FgXf5i9EJXMUXn4zM2-u/view
    https://drive.google.com/file/d/1ZEBzcFU8N1pl3LOQGZqLciXbXrQXzm3S/view
     
  4. Ratslayer

    Ratslayer

    Joined:
    Feb 6, 2014
    Posts:
    37
    @danUnity I want my animation guy be able to control character's position through same animation process as he does for all other motions. For example, if I have a sequence of animations Idle => Roll => Idle, I would like the my artist to be able to key root motion for Roll animation and then, once Roll transitions into the idle, have the character retain its new position, rather than come back to its original one. I don't know how else to explain it.

    Write defaults could be a solution, but only if I alternate between animations that have root motion and those that don't, otherwise it will still blend them like regular clips.

    I don't think layering will work, because root animation will still reset after playing, no matter the type of layer.

    The way Unity does it for regular animations is that it allows you to designate any bone as root bone and then, if you check enable root motion in the animator, it will convert the animated values for the root bone into position/rotation deltas. Those deltas are then applied to the root bone (or any other bone that you redirect the motion to through script). This way, if you have two animations with vastly different root motions, the animator will blend deltas, as if it's velocity, which means that all previous changes to position/rotation will remain. At least that's how I understand it.

    I want this kind of blending, or maybe something that can mimic it, but Unity only allows to choose root motion bone. No other customisation for such behaviour is available.
     
    mandisaw likes this.
  5. Ratslayer

    Ratslayer

    Joined:
    Feb 6, 2014
    Posts:
    37
    @sinjinn Hey. I have a very basic setup:
    upload_2020-4-18_21-37-23.png

    Skeleton is the base object with Animator and RigBuilder components.
    Armature is the skeleton imported from a Blender 2.8 mesh.
    Full Body IK is main rig object. It contains 2 children: Root and Rigs.
    Root is a Rig Hierarchy of empty objects that mirror essential Armature bones. Those are used as source objects for most constraints. Effectors are attached to those only.

    Rigs contains all the rigs which are as follows:
    upload_2020-4-18_21-42-10.png
    Body Rig Controllers are all Override Transforms that controll Rig bones of same name. They control only the rotation. Some are local, some are pivot, can't really tell which are which right now.
    Arms and Legs Rigs are all TwoBoneIKTransforms that control Arms and Legs using hand, elbow, knee and foot Rig bones. Nothing special here.
    Root rig is basically so that you can move the whole rig together. My Legs aren't children of the Body bone, which means that moving the hips bone no longer moves the legs. This is great most of the time, but sometimes I need to move everything together, which is what Root rig is for.
    Weapon Parent allows me to parent the sword to either hand, or the ground, if I wanted to.
    Weapon Transform is just an Override Transform for the Weapon Bone.

    I use Unity Animation Window to create animations, but I only move my rig bones and never the armature bones, so there is no Humanoid Muscle keys. The interface is lacking, but I have written a very simple UI window that allowed me to do some basic things, like previewing clips that aren't a state in AnimatorController (no idea why that is a feature).

    I am using Animancer to play all my animations and states are created through an internal state machine that comes with it. I'm really digging that package and it works pretty well with Animation Rigging, a few hickups not withstanding.
     
  6. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    149
    This is awesome. Thanks for the details. As a noob to IK and rigging as a whole, the bigger picture stuff, information as regard to which constraint should go where and why, and the workflows and tools involved, really help.

    Also checking out Animancer on Asset Store, they linked to a page on why to use it over Mecanim, which on first glance seems like a goldmine of information. Maybe it's just me, but someone breaking down whats wrong with something is always more interesting to read/watch, than a tutorial on how to do something.
     
    Last edited: Apr 19, 2020
    ProceduralCatMaker likes this.
  7. ChadGatling

    ChadGatling

    Joined:
    Feb 14, 2019
    Posts:
    4
    Whenever I setup the animation rigging as per the little video Unity did, when I hit play the root bone scales by like 100 and my character is doing his idle animation like 100 feet in the air. What gives?
     
  8. ProceduralCatMaker

    ProceduralCatMaker

    Joined:
    Mar 9, 2020
    Posts:
    108
  9. ProceduralCatMaker

    ProceduralCatMaker

    Joined:
    Mar 9, 2020
    Posts:
    108
  10. sinjinn

    sinjinn

    Joined:
    Mar 31, 2019
    Posts:
    149
    Any more info on any of the issues raised in these threads, please respond here.

    My issues now = what does a hint even do?
    Is it just all 2BIK constraints everywhere in a humanoid?
    what about angle ranges on bones....how do you control them ?
    Whats the best online guide/blog/video to learn the basics of rigging a human?
    How is AR integrated with code?

    Have a have a happy day.