No sound is being played when a mob dies

Godot Version



my problem is that the sound wont play when Health reaches 0, i know its because of the queue_free() but i have no idea what else to do?? sry for a noob question but i have looked everywhere on the internet but cant find a solution.

I’m gonna try and help you with the thought process here.

You say the sound doesn’t play because the node is getting free’d via queue_free(). That’s correct! I may then ask you:

Why does freeing (i.e. removing) the node stop the sound from playing; what changes?

1 Like

When the node is destroyed, it takes all its subnodes with it, including the AudioStreamPlayer2D. You can solve it by playing the sound from other class that is kept alive. Try my solution from this post:

1 Like

Okay so just to understand your example a 100% is the sound maneger its own scene that every other scene can access og is it just a node within the current scene?

It is a standalone scene that works as a singleton. Don’t forget to add it to Project Settings > Autoload.

1 Like