stride3d/stride · error · InvalidOperationException

Animation 2 is not set

Error message

Animation 2 is not set

What it means

A validation guard in the Start method of the AnimationBlend script/template asset: it fires when the Animation2 property is null when the animation starts playing. AnimationBlend requires two animation clips to blend between; the second one was never assigned, so the blend cannot be computed. It is one of a series of required-input checks (AnimationComponent, Animation1, Animation2).

Solutions

  1. Assign an AnimationClip to the script's Animation2 property in the editor
  2. Set Animation2 in code before Start, e.g. Blend.Animation2 = myClip
  3. Re-link Animation2 if the underlying animation asset was moved or renamed

Example fix

// before
new AnimationBlend { AnimationComponent = anim, Animation1 = clip1 };
// after
new AnimationBlend { AnimationComponent = anim, Animation1 = clip1, Animation2 = clip2 };
Defensive patterns

Strategy: type-guard

Validate before calling

if (blend.Animation2 == null) blend.Animation2 = defaultClip;

Type guard

bool ReadyToBlend(AnimationBlend b) => b.AnimationComponent != null && b.Animation1 != null && b.Animation2 != null;

Try / catch

try { scene.Run(); }
catch (InvalidOperationException ex) when (ex.Message == "Animation 2 is not set") { // re-link clip and restart
}

Prevention

When it happens

Trigger: Running a scene with the AnimationBlend script where the Animation2 property (second AnimationClip) was never assigned in the editor or via code.

Common situations: Assigning only Animation1 and leaving Animation2 blank; clip asset deleted or renamed so the reference is empty when re-added.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/14862819806bd4b0. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Animation/AnimationBlend.cs:45

    [Display("Time Scale")]
    public double TimeFactor = 1;

    private AnimationClipEvaluator anim1Evaluator;
    private AnimationClipEvaluator anim2Evaluator;
    private double currentTime = 0;

    public override void Start()
    {
        base.Start();

        if (AnimationComponent == null)
            throw new InvalidOperationException("The animation component is not set");

        if (Animation1 == null)
            throw new InvalidOperationException("Animation 1 is not set");

        if (Animation2 == null)
            throw new InvalidOperationException("Animation 2 is not set");

        AnimationComponent.BlendTreeBuilder = this;

        anim1Evaluator = AnimationComponent.Blender.CreateEvaluator(Animation1);
        anim2Evaluator = AnimationComponent.Blender.CreateEvaluator(Animation2);
    }

    public override void Cancel()
    {
        AnimationComponent.Blender.ReleaseEvaluator(anim1Evaluator);
        AnimationComponent.Blender.ReleaseEvaluator(anim2Evaluator);
    }

    public override void Update()
    {
        // Use DrawTime rather than UpdateTime
        var time = Game.DrawTime;

View on GitHub (pinned to 96fad776d2)