Animator
public sealed class AnimatorPlays clips over a node tree, one state at a time with a blend between the outgoing and the incoming.
The shape this is built around. An asset arrives with a handful of named clips of which one loops and the rest are gestures — Idle, Greet, LookAround is a literal example. That is a default state and a set of one-shots that return to it, so that is what the API says: set Animator.Default once, call Animator.CrossFade for a gesture, and the return trip happens without the caller tracking it.
Two states at a time, not N. A blend tree — several clips weighted by a parameter, layered masks, additive passes — is a character-controller feature, and building one into a viewport control would mean an API three times this size serving cases a viewport does not have. Two covers every transition between named states, which is what the files actually contain.
Constructors
| Member | Description |
|---|---|
| Builds an animator over |
Properties
| Member | Description |
|---|---|
| The layer everything on this class drives: It is separate from |
| The state in the foreground of the base layer, or null when nothing is playing. |
| The state a finished one-shot returns to, and the one |
| How long |
| Whether anything is playing on the base layer. |
| Every layer, base first, in the order they are combined. Read-only because a layer has to be registered against the node table when it is made — see |
| How far A delta, never a position, and every rule below follows from that: A looping cycle reports the step across the seam rather than the metre back to the start — the wrap is detected and the two halves are added.A crossfade blends the two clips' deltas, weighted as the pose is. Blending their positions would put the character at the average of two places and then walk it out of there.Seeking reports nothing. Writing |
| The joint whose translation is travel rather than pose. Null, which is off, and off is the default. A clip that walks its root forward is two different things depending on what the caller wants. As a pose it slides the character across the scene and snaps it back at the end of the cycle; as travel it is a metre per stride that belongs to whatever is carrying the character. Naming a node here says the second: the animator stops writing that node's translation and reports what it would have been as Off by default because it has to be. A character animated in place with a root that bobs is perfectly ordinary, and turning this on for it would set the whole thing bobbing across the floor — so the file cannot be allowed to decide, only the caller. |
| The clips this animator can play, by name. The base layer's — see |
Events
| Member | Description |
|---|---|
| Raised when a non-looping state reaches the end of its clip, on any layer, before the return to that layer's default. |
Methods
| Member | Description |
|---|---|
| Adds a layer on top of the ones already there, with its own copy of the states for Its own copy, and that is the point: a clip playing on two layers has two playheads, two weights and two ideas about whether it loops. Sharing them would make a gesture layered over a walk cycle scrub the walk cycle. |
| Moves every layer's playhead on by The library owns no clock, deliberately. |
| Blends the base layer into a state over Asking for the state already playing is a no-op rather than a restart: a button pressed twice should not stutter the gesture it is already showing. |
| Starts a state on the base layer immediately, with no blend. |
| Plays a state after the current one finishes, instead of returning to |
| Stops every layer and leaves the pose where it is. |