How to instance animations

Godot Version



How to instance the same animation multiple times?

Because 1 AnimationPlayer cannot play multiple animations at the same time, I decided I would save an AnimationPlayer node as a scene and then load it, instantiate it and add it as a child from script each time I want to run one of its animations. (So, there’s one AnimationPlayer node in the main scene that calls methods from its own script to instance this other AnimationPlayer node scene.) That was I can have multiple instances of the same animation without stepping on each others toes.

It seemed to work, but then I realized I should queue_free() the instanced AnimationPlayer after the animation ends, so I opened the saved scene from the FileSystem tab and added a Call Method track to each animation to call the animation player’s own queue_free() method. But now the problem is that the AnimationPlayer node is in its own scene tab, so it cannot see the node its animations are refering to (it’s supposed to call methods from a node in the parent scene) and I’m getting 200 error messages about that.

Can I not have an AnimationPlayer in its own scene that references a node in a parent scene? In script I reference nodes from other scenes a lot of times without any problems. What is the “normal” way to instantiate animations if not saving an AnimationPlayer node as a scene?

Thanks for reading.

The normal way would be either

  1. to have multiple same objects run other animations from the same set of animations: Instance the node with the animated parts together with the animation player


  1. to have many smaller animations: add under each animated node its own animation player with a single animation that gets played

For all other animation player applications I really dont see what your approach would be useful for.

1 Like

Thanks for the suggestions, they’ll be super useful. I also came up with a workaround: I can just use the script of the animation to reference a node in the parent scene. The animation can call methods in its own script and those methods do the hard part.

1 Like