There is no animation with name 'run'

Godot 4

I’m trying to play animations of an enemy I’m instantiating from another scene yet it gives me that error every time one spawns.

code for fight scene:

extends Node
@export var mob_scene2: PackedScene

func _ready():
func _on_timer_5_timeout():

var mob2 = mob_scene2.instantiate()
mob2.rotation = 0
mob2.position = Vector2(250, randf_range(-450 , 450))
var velocity2 = Vector2(randf_range(-150.0, -250.0), 0.0)
mob2.linear_velocity = velocity2.rotated(0)

code for enemy:

extends RigidBody2D
func _ready():

func _on_visible_on_screen_notifier_2d_screen_exited():

1 Like

Can you show the enemy’s AnimatedSprite2D frames? what is the name of their animations?

1 Like


Looks like it should work, double check the name doesn’t have any lingering whitespace before or after “run” i.e. "run "

Can you post a picture showing that entire screen?

add :

await get_tree().physics_frame

between that line

tried that

It didn’t work

It is set to autoplay so the script to play “run” on _ready is unnecessary, feel free to delete it if that’s a solution.

1 Like

oh yeah I only added that to see if that would change anything

what error it said?

With func _ready and everything within it deleted, it still doesn’t work?

The error that is the title of this thread:

There is no animation with the name “run”

func _ready() works only at scene’s start
when instancing _ready won’t do anything
try use _init() or _enter_tree()

nothing’s wrong here, have you tried making a new scene with exact same code to see if the “run” is detectable?

Check your export variable.
Did you have a mob_scene 1 and forgot to change that to 2?
@export var mob_scene2: PackedScene

it still gives the error that theres no animation with name run

nope it’s mob_scene 2

Can you show a picture of the inspector showing the filled in variable mob_scene2 in the mob_scene2 export?
I am not sure we are on the same page.

One thing that confuses me is that you are saying “mob_scene 2” or “mob_scene_2” when in the image your scene name is actually “mob2”.
When you assign a scene to an export it takes the name of the root node so if you print out your export it should print “mob2:<RigidBody2D>…”
You should test that out by printing your instantiated variable out:

var mob2 = mob_scene2.instantiate()

The next thing that bothers me is seeing 21 errors in that image. If those are 21 spawned mob scenes erroring then that makes sense.
If there are other errors in there, you may need to address them first.
I would instantiate 1 mob scene until you get that 1 running right.