Animation Rigging
The following document describes the setup process, constraint definitions and additional information on the Animation Rigging package [com.unity.animation.rigging].
What is Animation Rigging ?
Animation Rigging allows the user to create and organize different sets of constraints based on the C# Animation Jobs API to address different requirements related to animation rigging. This includes deform rigs (procedural secondary animation) for such things as character armor, accessories and much more. World interaction rigs (IK, Aim, etc.) for interactive adjustments, targeting, animation compression correction, and so on.
Workflow
The following sections present required components and steps to take in order to define an Animation Rig. This video also demonstrates package component usage to create a custom Animation Rig.
Rig Builder Component
The Rig Builder component lives alongside the Animator component and creates a Playable Graph that is appended to the existing Animator state machine. The Rig Builder component needs to be added to the GameObject that has the Animator component. Rig Builder needs to affect the same hierarchy as the Animator.
Using Rig Layers, the Rig Builder component allows for stacking of multiple Rigs, that can be enabled/disabled at any time.
Bone Renderer Component
The Bone Renderer component allows the user to define a transforms hierarchy to be drawn as bones for visualization and selection during the rigging process. These bones are not visible in the Game view. This, for example, allows the user to define his character deform skeleton for rigging purposes.
The look of the bones can be customized. The Bone Size, Shape and Color can be modified. Tripods of local axes can also be displayed and their size adjusted to accommodate user preference. The user can choose from one of the default looks; Pyramid, Line or Box.
Rig Component
The Rig component is the main entry point to all rig constraints for a given Rig. This component is assigned to a Rig Builder component under the Rig Layer field. There should only be one Rig component per control rig hierarchy. For multiple rigs, multiple control rig hierarchies can be assigned to different Rig Layers, and enabled/disabled independently. The main purpose of the Rig component is to collect all Constraint components defined under its local hierarchy and generate an ordered list (evaluation order) of IAnimationJobs, which will then be applied after the Animator evaluation. The order in which the jobs are evaluated is defined by component order and the way the rig hierarchy is constructed, since constraints are gathered using GetComponentsInChildren, which follows depth-first traversal as shown below:
In other words, grouping constraints under a GameObject allows the user to the manage the evaluation order of these constraints by modifying the hierarchy.
Control rig hierarchies should hold all the necessary rig elements such as effectors, constraints, and other objects/elements required by the constraint definitions. The root of a control rig hierarchy should be at the same level as the skeleton root, both under the Game Object holding the Animator. In other words, it should not be in the skeleton hierarchy, but rather live beside it.
Rig components, like all Constraint components, have a Weight property that can be used, animated, and scripted to enable/disable or ease-in/ease-out an entire control rig hierarchy.
Defining an Animation Rig
A Rig is a hierarchy of GameObjects using a minimum of these three components; Rig Builder, Rig + Constraint(s). A typical setup is to have a hierarchy of GameObjects [ex: Ninja.fbx] containing an Animator component on his root GameObject. To make this hierarchy available to the Animation Rig, the Rig Builder component is required. Once the Rig Builder component is added to the root, a Rig GameObject [ex: Rig Setup] can be created as a child of this root. To enable animation rigging, the Rig GameObject must contain the Rig Component. Then, to connect the Rig to the Animator, the Rig GameObject [ex: Rig Setup] needs to be assigned to the Rig Layer field of the Rig Builder component. This will associate the Animation Rig with the Animator.
The following illustration represents a schematic overview of the interdepencies between the Animator and the Animation Rig components.
Once the Rig GameObject (ex: Rig Setup) holding the Rig component is connected to the Rig Builder component, rig elements (effector GameObjects) that hold rig Constraint components can be added under the Rig GameObject (ex: Rig Setup) hierarchy. Different rig elements can be organized and hierarchically structured to create any kind of Rig, in order to accommodate any rigging requirement. Source GameObjects for Constraints, such as Target Effectors or Hint Effectors, can be placed under their associated Rig GameObject (ex: Rig Setup). In the following illustration, the Left Leg is acting as the Rig element that contains a Two Bone IK Constraint component which is at the same time the parent of both LeftFootEffector and LeftLegHint source objects.
Constraint Components
The Animation Rigging package contains a few predefined constraints that you can use to define your rigs.
- Blend Constraint
- Chain IK Constraint
- Damped Transform
- Multi-Aim Constraint
- Multi-Parent Constraint
- Multi-Position Constraint
- Multi-Referential Constraint
- Multi-Rotation Constraint
- Override Transform
- Twist Correction
- Two Bone IK Constraint
Scene Synchronisation to the Animation Stream
All constraint sources expose property transform fields with a synchronisation to stream checkbox. Any valid references living under the Animator component root specified in those fields will be declared as TransformStreamHandles. This means that we expect these transforms to be animated. However, if they are not you can enable the toggle in order to populate the values of that stream with what is currently defined in the scene at the beginning of the constraint pipeline. For example, if you declare a Two Bone IK Constraint with Target and Hint transform fields which are not animated, then enabling a sync operation will make these transforms editable. Note however that if animation was present for these transforms and the sync operation enabled, the orignal animated values would be ignored.
Technical details
Requirements
This version of Animation Rigging is compatible with the following versions of the Unity Editor:
- 2019.1 and later with .Net 4.x scripting runtime
Known limitations
Document revision history
Date | Reason |
---|---|
Nov 23, 2018 | First draft of package documentation |