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.
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.
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.
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.
Here are instructions for setting up Rigs on a character:
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 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.
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.
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.
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:
For the shuriken player ability, the ninja needs to be able to aim his throwing knives at any angle, 360 degrees.
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.
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.
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.
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.
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.
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)
The red part of the rig represents the inputs or desired targets, whereas the green represents the actual/current result.
Second, a DeformRig takes the final result of the ControlRig and applies it the model hierarchy + secondary piston movement:
The final result on the rig is then applied to the models or joints in the scene.
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.
Want to continue learning about rigging? Check out our courses and tutorials on the Unity Learn Premium platform.