How to get animation masking + root motion with Animation Rigging?

Heyo! I’ve been playing around with the Animation Rigging package for the past couple weeks and had some questions.

I’m an engineer on a small team of lovely folx. We don’t have a dedicated animator on the team, so I’m trying to develop a workflow for authoring 2D paper-doll-style animations that wouldn’t require our designers to learn a bunch of new tools. They’re very familiar with Unity though, so if we can accomplish all of what we need within Unity that’d be great! And Animation Rigging seems like it could make that possible.

So here’s a system I’ve worked out so far:

  • We have a prefab for each character.
  • Each character has a skeleton that’s just a hierarchy of empty game objects. This is great; authoring, and modifying these skeletons is super intuitive and easy.
  • Each character has a bunch of rigs and IK constraints that act on its skeleton. This is also wonderful; animating an arm with 2D limb IK is way better than rotating the bones manually. And we have the technical know-how on our team to create our own constraints too, so that gives us a ton of power and flexibility in the future.
  • Animations are authored entirely within Unity by recording changes to the IK constraints. So we don’t touch the bones themselves, we just record the effectors changing. Super easy! No extra tools needed!

So far all of this has looked super promising! But I’ve been stumped in figuring out how to properly implement two things: animation masking and root motion.

Unity provides Avatar Masks for animation masking. An Avatar Mask is generated from an Avatar, an Avatar is generated from a FBX model, and sadly since we’re not using models (again, our “models” are just hierarchies of empty game objects) it seemed like Avatar Masks wouldn’t be a feasible solution for us. But I was actually able to get around this with Unity’s FBX Exporter tool; now we can export our skeletons as FBX files, use those to generate Avatars, use those to generate Avatar Masks, and voila! (This is a shame from a workflow perspective, but if we have to do it, so be it.)

But this doesn’t actually work for us. From my testing, applying an Avatar Mask will cause the animation to ignore all of its IKs. Animations on the bones themselves work fine, but the Avatar Mask prevents the IKs from having any effect. And since our animations are authored entirely using IK changes, this means our animations are wiped out. This happens even if the constraints are children of the FBX, since the Avatar Mask still doesn’t know about the IKs even in that case. (I might be able to bake the IKs into the FBX… but that seems like it’d have a bunch of other downsides.)

I can imagine getting something like Animation Masking by having layers of rigs that overwrite one another, but then it seems like we would need to author our animations bearing in mind whether they’d be used for blending or not. Blending a run forward animation with a sword slash animation wouldn’t work if they both touched the same rig/effectors. So we’d instead need to blend a run forward animation (that animated one set of effectors) with a sword-slash-override animation (that animated another set of effectors set up to override the first set of effectors). Seems clunky.

Root motion has also eluded me. Suppose I animate moving my character forward using IKs such that they end the animation in a new spot. With Unity’s root motion, what I would do is animate moving the root object to the end position as well, and how this is supposed to work (by my understanding and testing) is this shouldn’t affect the animation at all, but when the animation ends that delta will be applied to the game object’s position. But I’m see it double count this movement: it does update the game object’s position, but it also moves the model forward by the same amount. So if I animate a character rolling 10ft forward and I animate the root object to move 10ft forward as well, then my character will appear to roll/slide 20ft forward and snap back 10ft afterwards. So not exactly usable.

So I guess my questions are:

  • If I author animations with Animation Rigging IK, how do I mask/blend them?
  • Is Animation Rigging intended to play well with Avatars + Avatar Masks?
  • How do I accomplish root motion when authoring animations with Animation Rigging IK?

Thanks! Happy to set up a minimal repro repo if it’d help.

Hi, I’ll try to answer your questions as best I can. I don’t have the full picture of what your workflow is, and a lot of it goes over what we cover specifically for Animation Rigging. Feel free to ask in the animation sub-forum otherwise, you might get other answers.

Did you try keyframing the constraints weight properties to enable/disable constraints in your animation. Removing Transforms from an Avatar Mask doesn’t mean that the associated constraint will stop evaluating, you need to do that separately.

Maybe try adding an extra layer in the state machine that controls the weights of your rigs/constraints.

Yes, as well as any other animation systems. Avatar Masks are evaluated in the State machine or the Timeline and thus apply their mask there. Animation Rigging is evaluated as a post-process step to the animation. It doesn’t have any knowledge of masks, it just processes the animation data after masks have been applied.

To author root motion directly in Unity, the indicated way is to indeed keyframe the root transform position and rotation. Now I’m not sure I understand why it’s an issue when you’re keyframing your character in IK, as you should only move your root transform through FK and not IK.

Otherwise, for FBX import, you can also set different sources for root motion. By setting a root motion node, you could define an alternate node where root motion is animated.

You can find the option under the Animation tab:
5901632--629810--Screen Shot 2020-05-26 at 1.28.47 PM.png

Hoping this helps :slight_smile: