stride3d/stride · error · InvalidOperationException

The animation component is not set

Error message

The animation component is not set

What it means

AnimationBlend (a generated script template) validates its required properties in Start(). If the AnimationComponent reference is null — nothing was assigned in the editor or via code — the script cannot build its blend tree and throws InvalidOperationException.

Solutions

  1. Add an AnimationComponent to the entity and assign it to the script's AnimationComponent property in the editor
  2. Assign AnimationComponent in code before the script starts (e.g. in the entity's initialization)
  3. Verify the script is attached to an entity with an AnimationComponent, not a bare entity

Example fix

// before
entity.Add(new AnimationBlend()); // AnimationComponent never set
// after
var anim = entity.Get<AnimationComponent>();
entity.Add(new AnimationBlend { AnimationComponent = anim, Animation1 = clip1, Animation2 = clip2 });
Defensive patterns

Strategy: type-guard

Validate before calling

var anim = entity.Get<AnimationComponent>();
if (anim == null) throw new InvalidOperationException("Entity requires an AnimationComponent");

Type guard

AnimationComponent ResolveAnim(Entity e) => e.Get<AnimationComponent>() ?? e.GetOrCreate<AnimationComponent>();

Try / catch

try { script.Start(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("animation component")) { // log setup error and disable script
}

Prevention

When it happens

Trigger: Attaching the AnimationBlend script to an entity without assigning its AnimationComponent property (in the Property Grid or in code) before the scene runs.

Common situations: Adding the blend script to an entity that has no AnimationComponent at all; forgetting to wire the property after copying the script to another entity.

Related errors


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

Appendix: source

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

    public AnimationClip Animation2;

    [DataMemberRange(0, 1, 0.01, 0.1, 3)]
    [Display("Blend Lerp")]
    public float BlendLerp = 0.5f;

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

View on GitHub (pinned to 96fad776d2)