Animancer v6.0 is currently available for testing.

Fading

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 Playing and Fading example demonstrates the use of this feature in more detail.

Durations

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.
    animancer.Play(clip, AnimancerPlayable.DefaultFadeDuration);

    // Fade over 0.8 seconds.
    animancer.Play(clip, 0.8f);

    // 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);
}

The Play methods that take a fade duration also have a FadeMode parameter to determine exactly how it works. That parameter is optional and will use FadeMode.FixedSpeed if not specified so the following two lines will do exactly the same thing:

animancer.Play(clip, 0.25f)
animancer.Play(clip, 0.25f, FadeMode.FixedSpeed)

Note that the fade duration is entirely separate from the length of the animation, so if the fade is too long it might not even finish fading in by the time the animation ends.

Custom Fade

All fades are linear by default, i.e. they move the AnimancerNode.Weight towards the AnimancerNode.TargetWeight at a constant AnimancerNode.FadeSpeed calculated when starting the fade. But that does not always give the smoothest transitions so Animancer includes a CustomFade system which allows you to modify a fade progress using a standard Interpolation.Function, an AnimationCurve, or a custom delegate.

The 3D Game Kit example demonstrates the use of this feature to smooth out the transitions between its Idle animations.

To use the system, simply call any of the static CustomFade.Apply methods right after calling animancer.Play normally:

[SerializeField] private AnimancerComponent _Animancer;
[SerializeField] private AnimationClip _Clip;

private void Awake()
{
    // Start fading the animation normally.
    var state = _Animancer.Play(_Clip, 0.25f);
    
    // Then apply the custom fade to modify the state you are fading in.
    CustomFade.Apply(state, Easing.Sine.InOut);// Use a delegate.
    CustomFade.Apply(state, Easing.Function.SineInOut);// Or use the Function enum.
    
    // Or apply it to whatever the current state happens to be.
    CustomFade.Apply(_Animancer, Easing.Sine.InOut);
    
    // Anything else you play after this will automatically cancel the custom fade.
}

The CustomFade system is located in the Utilities folder, meaning that its source code is even included in Animancer Lite to demonstrate how the system can be extended, however it relies on the ability to set the AnimancerNode.Weight which is a Pro-Only Feature so it cannot be used in runtime builds unless you purchase Animancer Pro.

Curve Preset Libraries

AnimationCurve fields are convenient for easily visualising and editing curve functions in the Inspector, however they can be somewhat tedious to set up complex and consistent curves. Fortunately, Unity allows you to define Curve Preset Libraries so you can simply download the Animancer Curve Presets from here and use them as a starting point for your own curves. Note that these curves were configured by hand with the minimum number of keyframes for efficiency. They do not cover the exact same set of functions as the Easing class and any that are the same will have slight differences in their exact values.

Individual Fading

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.

Since AnimancerLayer also inherits from AnimancerNode, this also 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.