DEV Community

Yiren Labs
Yiren Labs

Posted on Originally published at atlas-errors.petersoncool.workers.dev

Godot 4: AnimatedSprite2D has no SpriteFrames resource assigned

What you see

When the scene runs, the console prints A SpriteFrames resource must be created or set in the "Sprite Frames" property in order for AnimatedSprite2D to display frames. The node is present in the tree, its texture slot may look filled in the editor preview, but nothing renders in the game and no animation plays. The message appears the moment playback tries to fetch the current frame, not at the moment the node was placed.

Why it happens

AnimatedSprite2D reads its frame list from a separate SpriteFrames resource, not from a texture assigned directly on the node. When that resource is empty, the current-frame lookup finds zero animations, prints this notice, and keeps rendering nothing. Common causes: the node was added by hand and never connected to a SpriteFrames .tres; a packed scene was instantiated and its resource reference dropped; or a script calls play() before assigning frames at runtime. The texture you see in the editor thumbnail belongs to the imported PNG, not to a usable animation track, which is why the preview can look fine while the runtime stays blank.

Confirm it

Select the AnimatedSprite2D node in the Scene tree dock and inspect the Sprite Frames property in the Inspector. An empty entry, with no resource name shown, means nothing is assigned. To catch runtime cases, search your scripts:

findstr /s /n "play(" *.gd
Enter fullscreen mode Exit fullscreen mode

A healthy setup shows a SpriteFrames resource with at least one animation and one frame, and get_sprite_frames() returns a non-null object. A broken setup has an empty Sprite Frames slot, or a resource whose default animation contains zero frames, so the frame count reads zero even though the resource slot itself looks filled.

Fix it

Either create the resource in the Inspector (Sprite Frames, New SpriteFrames, add an animation, drop frames in), or build and assign one in code before you call play:

extends AnimatedSprite2D

func _ready() -> void:
    var frames := SpriteFrames.new()
    frames.add_animation("walk")
    var sheet: Texture2D = preload("res://assets/walk.png")
    frames.add_frame("walk", sheet, 0.1)
    frames.set_animation_speed("walk", 8.0)
    set_sprite_frames(frames)
    play("walk")
Enter fullscreen mode Exit fullscreen mode

Add at least one frame to the default animation, since an animation with no frames still renders nothing. After the change, log get_sprite_frames() != null and get_sprite_frames().get_frame_count("walk") in _ready; the frame count must be greater than zero before play() runs, and the notice must disappear from the console.

Options

If you reuse the same frame setup across many enemy and NPC scenes, the same resource check can be applied to a whole folder of scenes offline, with no upload: the full version is $19 and there is a free sample on the fixer page.

Engine message and source location for this AnimatedSprite2D notice: the error reference.

Batch resource checks across scene folders: the fixer page

Companion reference page for this engine message: https://atlas-errors.petersoncool.workers.dev/error/godot-animatedsprite2d-missing-spriteframes/

Top comments (0)