Introducing the Animation Rigging preview package for Unity 2019.1

The Animation Rigging package for Unity 2019.1 enables users to set up procedural motion on animated skeletons at runtime. You can use a set of predefined animation constraints to manually build a control rig hierarchy for a character or develop your own custom constraints in C#.This makes it possible to do powerful things during gameplay such as world interactions, skeletal deformation rigging, and physics-based secondary motion.

We’re happy to introduce the new Animation Rigging as a preview package for Unity 2019.1. This blog post will provide an introduction and some examples of how you can use it. Please also check out the video of our Animation Rigging GDC 2019 presentation, it’s freely accessible on the GDC Vault.

Getting started

You can now install the Animation Rigging package in your Unity projects from Package Manager. (Be sure to show Preview packages in the Advanced tab of Package Manager) The package page includes links to documentation along with some samples to help everyone get up to speed with using the package. This is our first release as a preview package for Unity 2019.1. You can also try out our next iteration for 2019.2 in the public beta. Using this upcoming version, you can use the Animation Window to author your own constraints animations with live feedback.

A brief note about what we mean by preview: please be aware that things in this package will change as we update to new versions. The exciting part is that you have the opportunity to influence our development and make sure it works for what you need. So please stay in touch with us and let us know how it goes. We are very eager to hear your input.

Animation Rigging overview

The Animation Rigging package provides a library of rig constraints that you can use to create procedural motion at runtime. This is commonly known as runtime rigging. The constraints are set up in groups called Rigs, which are assembled in the Rig Builder component that is assigned to the asset’s Animator Root.

This enables users to do powerful things with animated skeletons during gameplay, such as world interactions. For example, when a character’s hands interact with a prop, or to aim at a target in the world. It’s also possible to get higher quality rigging using procedurally controlled bones for skeletal deformation rigging, such as twist correction for shoulders and wrists on skinned mesh characters. We also have physics-based constraints that can be used for dynamic secondary motion on character rigs.

Bone Renderer

For working with rigs in the Unity Editor, it helps to see and interact with the skeleton in Scene view. We now have the Bone Renderer component, which allows you to add a list of transforms and display them in a variety of visual styles.

It often helps to organize parts of the skeleton using multiple Bone Renderer components. Here is an example where the same character has multiple Bone Renderer components so that the body, fingers and twist bones can each have their own display styles. This helps to facilitate different artist workflows such as rig setup, keyframing or gameplay debugging.

Rig Builder and Rigs

First, we need to add the Rig Builder component to the Animator root. This is the same GameObject where the Animator component is assigned. Typically, this is the topmost transform in the rig hierarchy.

Next, we can create a new child GameObject and that is where we will add the Rig component.

Finally, the Rig gets assigned to the Rig Layers list in Rig Builder.

This is the minimal valid rig setup. In the next steps, we add constraints.

The really great thing about Rig Builder is that the Rig Layers list allows for multiple rigs as seen in the image above. This is very useful for creating specialized behaviors that can be turned on and off during gameplay. And to make it even more useful, each Rig has its own weight value so it can be blended with the other Rigs.

Rig Constraints

Rig Constraints are the building blocks that are used to assemble rigs and produce procedural motion at runtime. They’re designed to be modular and general-purpose so that they can be combined in many different ways to solve the needs of your animation game designs in runtime.

Here is the list of Rig Constraints that are being released with the package.

Here are steps for how to set up a Rig Constraint. In this example, we’re using the TwoBoneIK Constraint.

Lastly, when Play is pressed we can see the Constraint evaluates at runtime.

Rig Constraints samples

The best way to get started and learn how the Rig Constraints work is by checking out the samples included with the package. Inside of Package Manager, there is a button to import the samples into your project. There is a scene for each constraint that demonstrates how it works.

Gameplay examples

Runtime rigging happens during gameplay. So in order to try out how this works, we made a quick gameplay prototype using some existing Unity sample content.

We implemented these basic player controls and used the Animation Rigging package to get some cool gameplay mechanics very easily. Here is a quick video of what it looks like:

Let’s take a look at each of these features so you can see how we made the runtime rigs.

Skeletal Deformation Rig

The ninja’s skeleton already had twist bones and skin weights set up to begin with. In Unity, we added TwistCorrection constraints to fix up the deformation on his arms and legs. The video shows what it looks like when these constraints are turned off. With the twist correction applied, the movement feels much more natural, like real anatomy and clothing:

Vertical Aim Rig: Shuriken

For the shuriken player ability, the ninja needs to be able to aim his throwing knives at any angle, 360 degrees.

To set this up we first added some new virtual bones to his skeleton.

Virtual bones in Unity are when you add new Transforms into the skeleton hierarchy and save them with the prefab. These can be animated like any other bone. They can be considered virtual because they may only have keyframes in the animation clips that need them, which saves memory elsewhere where they are not needed.

Next, we added a TwoBoneIK Constraint to the left arm and set the virtual bones as the IK targets.

The IK targets were then animated in a new animation clip where he throws the shuriken. This clip is set up in the ninja’s Animator State Machine as a replacement layer. Both this layer and the vertical aim rig are activated on button press.

Finally, we made a 1D Blend Tree to drive the Aim Vertical virtual bone, which is the parent of the IK targets. This gets driven by player input, the vertical axis of the left analog thumbstick on a gamepad controller.

As a result, this animation layer overlays on top of any animation the ninja may be playing. This always works whether he is running, jumping, crouching or even attacking with his sword he can immediately throw a shuriken as a ninja should.

Vertical Aim Rig: Katana

The ninja’s katana also needs to be able to aim vertically in order to hit targets that might be on the ground or overhead. We made this building on top of the shuriken rig. It uses the same 1D Blend Tree to control aiming.

Sword animations bring a new factor: the horizontal rotation. It’s very important for this horizontal aim to be perfectly straight so that the sword trail effect looks smooth. It can be difficult to make this look straight using only skeletal animations because even if the poses are perfect, there are often imperfections in sub-frames. This is because of the way the interpolations solve on the arm’s FK bone chain. The best way to fix this is by using a Multi-Aim Constraint.

We set up a new virtual bone and moved it out in front of the katana. Then we assigned this as the target of a Multi-Aim Constraint. The source object of this is the right-hand grip bone, which is the parent of the katana model.

Next, we added another virtual bone as the parent of the aim target and used a Position Constraint to keep it centered on the ninja’s chest.

Finally, we opened the sword swipe animation clip and added keyframes for rotating the parent of the aim target in sync with the motion of the arm.

The result is that the Multi-Aim Constraint corrects any imperfections in the horizontal rotation arc of the sword. Even when the animations are slowed down and have particle effects added as shown in the above video, the sword strike is always straight and true.

Butterfly Familiar Rig

Here is another example of how Rig Constraints helped us to make a follower character. We used the DampedTransform Constraint to make the butterfly follow a target Transform in the ninja’s prefab. It also uses a Multi-Aim Constraint to shine a spotlight that always aims at a target in front of the ninja wherever he goes.

You might recognize the butterfly model from our earlier blog post on the HD Lit Master Node for Shadergraph. What we didn’t know at the time is that this is the ninja’s messenger butterfly – he gives him power-ups and special attacks. Most importantly it keeps him company while he runs through the Megacity. Anyway, you can invent whatever cool gameplay mechanics you like and the Animation Rigging package makes it easy to implement.

Mechanical Crane example

The animation rigging constraints can not only be used for characters, but also for anything else. In this example, we used these constraints to build a futuristic mechanical crane rig. The goal was to create a rig that is entirely driven by inputs and constraints at runtime. There are no animation clips in this example, as all motion is derived from two gamepad joystick inputs and one button to trigger the clamp & release of the container.

ControlRig

In this example, we took the approach of creating two rigs. First, a ControlRig that basically mimics the model hierarchy in order to input and solve the desired result in an animation stream (aka the ControlRig)

DeformRig

The final result on the rig is then applied to the models or joints in the scene.

Rig Structure

The inputs for the crane’s arm are driving rig effectors using a simple script and the Rig Transform component to obtain the proper scene/input evaluation. These inputs are then damped onto a second effector. The remaining effectors, including the container rotation and clamps, are children of this damped result. In this example, the ControlRig uses 15 constraints: Damp for the inputs, 2BoneIK for the arm, multiple constraints for the clamps and container release. The DeformRig uses a flat list of constraints: Aim & Multi-Position for the pistons & Multi-Parent Constraints for the rig-to-model remapping.

There are, of course, many ways that this example could have been rigged to obtain the same or similar result. Keep in mind that the rig hierarchy (order of GameObjects in the scene) controls the order in which the constraints are evaluated. This is extremely important in cases like this, where certain constraints need to be evaluated in a specific order.

Hope you’ve found this blog post useful in understanding how to manage inputs, Rig Transforms and different types of rigs & constraints. Have fun! We’re looking forward to hearing your feedback on the forums.

The GDC Vault has its own restrictions about how videos can be shared that are beyond our control. For now it is only available to watch on the GDC Vault website through this link:https://www.gdcvault.com/play/1026151/

Hi Christougher,
The example content we currently have available for download is the mechanical crane. We have versions available on GitHub for both 2019.1 and 2019.2. We do hope to release more example content including the ninja later this year.

This is so going in the right direction – I’m planning to mix animation data from various sources (mocap system, neural network, regular fbx animation, IK etc) and the new rigging system looks like it may enable me to this cleanly and effectively.

However, in trying to follow the demo movie (Unity Runtime Rigging Setup on youtube) I am completely stumped by how he manages to select the armature in the Hierarchy whilst keeping the ‘Ninja’ prefab’s root gameobject selected in the Inspector (22 seconds into the movie) – how does one select one thing in the Inspector whilst selecting something else in the Hierarchy – what magic is this, and how do I perform it!?

Edit: Further on in the movie, I noticed the presenter uncheck the padlock icon at the top of the Inspector window. I guessed then that the icon is a selection lock – I tried it and was able to select the joints in the hierarchy whilst keeping the root gameobject selected in the Inspector – my issue is resolved.

Cool, glad to hear you figured it out. Yes, it can be useful sometimes to lock the inspector so it stays focused on a particular GameObject. You can also open a second instance of Inspector so you can also see the selected GameObject. I agree it’s not the most obvious workflow, so we will keep an eye out for how to make it easier to discover.

I’m excited to hear how it goes with your project. This does seem like something that would be facilitated by the runtime constraints in Animation Rigging. Definitely stay in touch with us about how that goes and feel free to post a thread on our forums (link is included in the blog) if there are good discussion topics that come up.

I’m so so happy features built into humanoid are being transferred into components, with a billion new features to boot! Quick question though, how do those twist bones work? The ones that are built into the rig before import.

Hi Josh,
Glad to hear you are happy about these features! The Twist Correction constraint gets added to bones that are already in your skeleton with skin weights. The constraint blends rotation on one axis to the target transform. So this just sets rotation correctly during runtime, but the bones need to be there to begin with. I hope that helps clarify how they work.

I assume that characters already have to be skinned to get this new stuff work?
Many character-files out there provide geometry in T/A-pose but have no bones/skin.
So I would like to get a skinning tool in Unity similar to the Mixamo-thing but better ;-)

Hi Carsten,
That is correct, your character needs to have a skeleton and skin weights already set up. Thanks for the suggestion, I agree it would be nice to have tools for creating that content in Unity.

Hi Andre,
To speak to your question about performance costs, this is relative to how much computation happens within each constraint solver algorithm. Simple constraints will be more performant than complex ones. We do have the added benefit of automatic multi-threading with the C# Jobs System. There isn’t any reason why this wouldn’t work on mobile platforms. There is the ongoing trade-off of processor vs. memory, which can mean different choices for mobile based on what kind of game you are making.

For DCC importing of constraints, Unity does have a different kind of constraint that is meant to serve that purpose. Those can be found on the Component > Miscellaneous menu (Aim, Position, Rotation, Scale, Look At and Parent). These will be exported from DCC if you FBX settings have export constraints set to true, and they will be imported into Unity. However, the constraints in Animation Rigging are not intended to serve this purpose and are instead built for runtime so that games and applications can have the performance and range of functionality that is needed for that set of use cases.

For your final question: yes, it’s definitely possible to enable/disable these constraints by LOD distance. You can manage constraints active state and weight value from C# scripts very easily.

Hi Wendelin,
Yes, there is more information about physics-based constraints in our GDC Developer Days presentation. The link to that video is included at the top of the blog post. In that presentation we describe how to build a new physics-based constraint called the Jiggle Chain Constraint. There is also an example scene included with the package that shows how to used the Damped Transform Constraint. I hope that helps.

This is definitely going in the right direction. It is a bit disappointing that the out-of-the-box constraints do not include a constrained FABRIK or general constrained CCD IK solver. This is the thing I need most. Specifically, I need more than two bones and I need to specify rotation limits at each bone. Bonus would be to handle sliding joints in the IK solver. The game we are working on now uses 6 bone chains with rotation joints at each. We use the Final IK plugin for the constrained IK. If we could get Rigging up to that level, it would be extremely useful.

Hi David,
Great suggestions and yes, we understand the importance of different kinds of IK solvers like FABRIK and CCD. We do intend to add more constraints in future releases, but in the meantime we left it open ended for users to extend the package and develop their own constraints in C#. The package architecture handles all of the internal work for you to get access to Animation Stream and multi-threading with the C# Jobs System. Our GDC Developer Days presentation has more instructions how to do that if you are interested. The link to that is included in the blog post.

Hi Kaz,
It looks like Cinema Suite is an Asset Store plugin provided by an external developer, so we don’t maintain that ourselves. I haven’t used it so I can’t say for sure if it is compatible. By reading the description it looks like it does Kinect mocap and as far as I can tell that should work fine with the Animation Rigging package.