As explained on the Playing Animations page, there are several different sets of parameters you can specify when calling
AnimancerComponent.Play depending on whether you want it to immediately snap to the new animation or gradually fade it in over time while fading the previous animation out (known as "Cross-Fading").
Fading is not generally used for
Sprite animations because they cannot be blended, however is very useful for Skeletal Animations because it allows a character model to smoothly transition from the ending pose of one animation into the starting pose of another animation without requiring both poses to be exactly the same. It also means that the transition can still be smooth if an animation is interrupted at any time.
The Transitions example demonstrates the use of this feature in more detail.
Fading is supported in Animancer Lite, however the ability to specify a custom fade duration is a Pro-Only Feature so it will always use the default 0.25 seconds in runtime builds unless you purchase Animancer Pro.
void CrossFadeExample(AnimancerComponent animancer, AnimationClip clip)
// Default 0.25 seconds fade duration.
// Fade over 0.8 seconds.
// Fade for 20% of the new clip's duration.
animancer.Play(clip, clip.length * 0.2f);
animancer.Play(clip, 0.2f, FadeMode.NormalizedSpeed);
// Fade for 10% of the old clip's duration.
animancer.Play(clip, animancer.States.Current.Length * 0.1f);
When you call the
Play method with a fade duration, it internally calls
AnimancerNode.StartFade on every animation. For example, if you have Idle, Walk, and Jump animations and you call
Play(walk, 0.25f), it will call
StartFade(1, 0.25f) on the
walk state and
StartFade(0, 0.25f) on the others. This means you can use
StartFade to control individual states rather than only cross-fading all of them at once.
AnimancerLayer also inherits from
AnimancerNode which means that you can fade entire Layers in and out. There is no
CrossFade for layers because they are not commonly used in that manner, but you can achieve the same thing by calling
StartFade(0, fadeDuration) to fade some layers out and
StartFade(1, fadeDuration) to fade others in. The Layers example makes use of this feature to fade out the upper body layer once it is no longer needed so that the base layer can resume controlling the character's entire body.