API Reference · Animation

AnimationLayer

Namespace: Ava3D

public sealed class AnimationLayer

One crossfading player: a set of states, which of them is playing, and how its pose meets the ones below it.

Every animator has at least one — Animator.Base, which is what Animator.Play and the rest of that class's state API drive. Extra layers exist so that two things can be true of a character at once: walking and waving, breathing and talking.

The layer owns the playhead and nothing else. It does not touch a node, because a pose is the result of every layer and no single one of them knows what the others did — Animator.Advance samples them in order and writes the answer once.

Properties

MemberDescription
AnimationBlend Blend { get; set; }

How it meets the layers beneath it. The base layer is always AnimationBlend.Override.

AnimationState Current { get; }

The state in the foreground, or null when nothing is playing here.

string Default { get; set; }

The state a finished one-shot returns to. Null leaves the pose where the one-shot ended.

float FadeDuration { get; set; }

How long AnimationLayer.CrossFade takes when it is not told. 0.2 s.

bool IsPlaying { get; }

Whether anything is playing on this layer.

AnimationMask Mask { get; set; }

Which nodes it may move, or null for all of them.

string Name { get; }

What to call it. Only for a caller's own bookkeeping; nothing here is addressed by it.

AnimationReference Reference { get; set; }

What an additive layer measures against. Ignored by an overriding one.

AnimationStateCollection States { get; }

The clips this layer can play, by name.

float Weight { get; set; }

How much of this layer reaches the pose, from 0 to 1.

On an AnimationBlend.Override layer it is a blend towards what is underneath; on an AnimationBlend.Additive one it scales the difference being added, so half a wave is half as big a wave rather than a wave half the time.

Events

MemberDescription
event EventHandler<AnimationEventArgs> Finished

Raised when a non-looping state on this layer reaches the end of its clip.

Methods

MemberDescription
AnimationState CrossFade(string name, Nullable<float> seconds = default)

Blends into a state over seconds, or AnimationLayer.FadeDuration when that is null.

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.

AnimationState Play(string name)

Starts a state immediately, with no blend. Restarts it if it is already the current one.

void Queue(string name)

Plays a state after the current one finishes, instead of returning to AnimationLayer.Default.

void Stop()

Stops everything on this layer and leaves its contribution where it is.

See also