The Animation Rigging package can be extended with C# to enable precise results for specific gameplay needs. In this talk at Unite Copenhagen, Unity Animation Developer Sven Santema demonstrates how to build custom rig constraints in C#. The goal was to show how you can easily extend the package to add secondary motions on your character rigs at runtime and how you can create authoring constraints to tweak your current animation assets within Unity.
Speaker: Sven Santema – Unity
Watch the session on YouTube: https://youtu.be/xwwK0lAlSyY
3. What is Animation Rigging?
3
— Runtime Rigging
— Procedural motion for animated skeletons at runtime
— Animation Authoring
— Author new and existing clips
— Preview package since 2019.1
— Modularity
4. Animation Rigging Overview
4
Start with a character
that has a skeleton
and animations
Add Rig Builder
and Rigs
Add Rig Constraints
to the Rigs
Create procedural
motion at runtime
7. Rig Constraints
7
— Contains a core set of constraints
— World Interactions
— Procedural secondary animation
— Skeletal deformations fix up
8. Rig Constraints
8
— Contains a core set of constraints
— World Interactions
— Procedural secondary animation
— Skeletal deformations fix up
— Evaluation order based on hierarchy view (depth first)
9. Put more Rig Constraints together
9
— Single idle animation playing on all ninjas
— Various constraints, with keyframed properties
10. Lets Get More Technical
10
— Every rig constraint is an C# Animation Job
— Animation C# Jobs
– Frictionless multi-threaded scheduling performed by the Animator
– Enables you to modify an animation pose on the Animator thread
prior to writing it back to the GameObjects
— Animation Stream
– TransformStreamHandles
– PropertyStreamHandles
— SceneHandles
11. Open Rigging Toolkit
11
— Modify existing constraints or create completely new
constraints
— Each production is unique
– Constraints can be custom made
– For potential performance gains or unique behaviors
12. Scripting a custom constraint
12
— Boils down to declaring a RigConstraint
13. Scripting a custom constraint
13
— Boils down to declaring a RigConstraint
14. Scripting a custom constraint
14
— Boils down to declaring a RigConstraint
15. Scripting a custom constraint
15
— Boils down to declaring a RigConstraint
32. Sync Values to Animation Stream
32
— First job to run before evaluating any of the rig layers
— Pushes latest scene values to the animation stream
– Only if these have NOT previously been animated
– Makes latest values available to all downstream jobs
— Flag constraint fields using [SyncSceneToStream]
– Works on a limited set of data types
– Float, Int, Bool, Vector[2,3,4], Quaternions, Vector3Int,
Vector3Bool
– Transform, Transform[], WeightedTransform,
WeightedTransformArray
38. External forces (gravity, wind,
etc.)
Root Tip Particle (P)
Root
Tip
Jiggle Chain Constraint
38
Constrain particle at dynamic
offset distance
C(P, TR) = |P - TR| - Offset
Constrain particle to target
C(P, T) = |P - T|
Frame N + 1
39. Solve particle dynamics and
update particle position
Rotate object given new aim
vector computed from TR and
particle position
Jiggle Chain Constraint
39
Root
TipTip
Frame N + 1
45. Summary
45
— Shown how to write a custom constraint
— Had a look behind the scenes
— Illustrated how to make complex constraints
— Look forward seeing your creations!
— Want to learn more?
— Two blog posts
— GDC vault
— Siggraph talks
— Share your feedback with us
46. Thank you!
46
— We look forward to hearing your feedback on Animation Rigging
https://forum.unity.com/forums/animation-previews.141/
Sven Santema - svens@unity3d.com Jiggle Chain Constraint Twist Chain Constraint