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
- Assign an AnimationClip to the script's Animation2 property in the editor
- Set Animation2 in code before Start, e.g. Blend.Animation2 = myClip
- 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
- Treat Animation1/Animation2 as a pair; never assign one without the other
- Verify animation assets are imported (Asset compilation output) before referencing them
- Use the Property Grid's required-field review before shipping a scene
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
- Animation 1 is not set
- The animation component is not set
- Custom strides is not supported with packed PixelFormats
- A region can only be specified for Textures with…
- A texture with size [ ] already exist with the same output…
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)