Creating Custom States

Pro-Only: Animancer Lite allows you to try out this feature in the Unity Editor, but it will not be available in runtime builds unless you purchase Animancer Pro.

You can implement your own state type by inheriting from AnimancerState (or any type derived from it). Every state must override CreatePlayable to set the AnimancerNode._Playable, otherwise you will get the following exception in various places throughout the system: ArgumentException: The playable passed as an argument is invalid. To create a valid playable, please use the appropriate Create method.

using Animancer;
 
public sealed class MyState : AnimancerState
{
    private AnimationClip _Clip;

    public ClipState(AnimationClip clip)
    {
        _Clip = clip;
    }

    protected override void CreatePlayable()
    {
        _Playable = AnimationClipPlayable.Create(Root._Graph, _Clip);
    }
}