Different animation players effecting each other when they are not supposed to

Godot Version

Godot 4.3

Question

I want to spawn in a projectile in a scene by preloading the projectile in a PackedScene variable and then spawning it when I press enter like this:
pic1

“CRUSHER” is the packed scene. For this projectile I have set up an animation player that makes it at first creep into the screen and then fly past it. However I want the projectile to spawn from a random side of the screen and so I would have change the animation according to that. Here’s how I do it:


(keyframes are already set up in the player)

It works perfectly, except for one weird thing:
If I spawn multiple at the same time it seems that the animation of the last one I spawn overwrites the animations of the previous and they follow it. I thought they were separate from each other? For some reason changing the AnimPlayer for one through code changes it for all the others. I know they are the same scene but aren’t they different objects? It might just be me not understanding how this works but it would be great if someone what I’m doing wrong.

Here are the images on imgbb incase they don’t show up:

Can I ask you to try out the following:

  • Go into the scene where you have the AnimationPlayer
  • Go into the property AnimationMixerLibraries
  • Click on the AnimationLibrary resource
  • Check the box that says “Local to Scene”
  • Save the scene

Does doing so make it that every instance of an instantiated crusher scene treat their animations individually?

That sounded promising, but unfortunately nothing changed

Then I would like to propose the following to you.

  • Create two animations
  • One is called rise1, the other is called rise2
  • you preset all the tracks accordingly
  • based on dir <= 2, you play either one animation or the other animation.

Combined with that, you can even go further:

  • Save the string “rise” into a variable.
  • Based on dir <= 2, you can adjust “rise” into “rise1” or “rise2” and call that instead.
    • Instead of $Move.play("rise"), you do $Move.play(rise_var) or something

I found a way to get it to work. I make a duplicate of the animation, change its animation, add it to the AnimPlayer and play it. You still have to set it so it’s local to the scene otherwise it won’t work.

1 Like