{"record":{"id":"2614f5d7bcc2cc8a","repo":"stride3d/stride","slug":"the-animation-component-is-not-set","errorCode":null,"errorMessage":"The animation component is not set","messagePattern":"The animation component is not set","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Animation/AnimationBlend.cs","lineNumber":39,"sourceCode":"    public AnimationClip Animation2;\n\n    [DataMemberRange(0, 1, 0.01, 0.1, 3)]\n    [Display(\"Blend Lerp\")]\n    public float BlendLerp = 0.5f;\n\n    [Display(\"Time Scale\")]\n    public double TimeFactor = 1;\n\n    private AnimationClipEvaluator anim1Evaluator;\n    private AnimationClipEvaluator anim2Evaluator;\n    private double currentTime = 0;\n\n    public override void Start()\n    {\n        base.Start();\n\n        if (AnimationComponent == null)\n            throw new InvalidOperationException(\"The animation component is not set\");\n\n        if (Animation1 == null)\n            throw new InvalidOperationException(\"Animation 1 is not set\");\n\n        if (Animation2 == null)\n            throw new InvalidOperationException(\"Animation 2 is not set\");\n\n        AnimationComponent.BlendTreeBuilder = this;\n\n        anim1Evaluator = AnimationComponent.Blender.CreateEvaluator(Animation1);\n        anim2Evaluator = AnimationComponent.Blender.CreateEvaluator(Animation2);\n    }\n\n    public override void Cancel()\n    {\n        AnimationComponent.Blender.ReleaseEvaluator(anim1Evaluator);\n        AnimationComponent.Blender.ReleaseEvaluator(anim2Evaluator);\n    }","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Animation/AnimationBlend.cs#L21-L57","documentation":"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.","triggerScenarios":"Attaching the AnimationBlend script to an entity without assigning its AnimationComponent property (in the Property Grid or in code) before the scene runs.","commonSituations":"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.","solutions":["Add an AnimationComponent to the entity and assign it to the script's AnimationComponent property in the editor","Assign AnimationComponent in code before the script starts (e.g. in the entity's initialization)","Verify the script is attached to an entity with an AnimationComponent, not a bare entity"],"exampleFix":"// before\nentity.Add(new AnimationBlend()); // AnimationComponent never set\n// after\nvar anim = entity.Get<AnimationComponent>();\nentity.Add(new AnimationBlend { AnimationComponent = anim, Animation1 = clip1, Animation2 = clip2 });","handlingStrategy":"type-guard","validationCode":"var anim = entity.Get<AnimationComponent>();\nif (anim == null) throw new InvalidOperationException(\"Entity requires an AnimationComponent\");","typeGuard":"AnimationComponent ResolveAnim(Entity e) => e.Get<AnimationComponent>() ?? e.GetOrCreate<AnimationComponent>();","tryCatchPattern":"try { script.Start(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"animation component\")) { // log setup error and disable script\n}","preventionTips":["Fill all [DataMember] script properties in the Property Grid before saving the scene","Validate required script properties in a scene-start checklist or editor validator","Avoid copying scripts between entities without re-linking component references"],"tags":["stride","animation","script"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}