Audio is not playing even though my print function is showing the variable is working

Godot Version

4.2.1

Question

As you can see in the picture I have the audio player set to play when the collision happens, and the print function does work, but the audio itself is not playing. If I click “playing” on the audio streamer the sound works so I know the audio file works. Also, if I make it wait for the audio to be finished it will play the sound. I saw a similar post on here from a few weeks ago but the solution there did not work for me.

Looks like you’re freeing the parent (and therefore the AudioStreamPlayer) before it gets a chance to play. You can hide the node and connect AudioStreamPlayer’s finished signal to queue_free(), or reparent the AudioStreamPlayer first.

(Note: This is also a case where it can be handy to have an audio manager with common AudioStreamPlayers as an autoload or otherwise globally accessible, so you don’t have to worry about it.)

I had a feeling it was something like that but all of my over-engineered solutions to making it have time to play were not working. I do have a video saved somewhere on an audio manager so I’ll look into setting that up as that seems like it makes a lot more sense from an organization standpoint.

1 Like

Yeah, and there are some plugins that will do the work for you. I’ve been meaning to set up Godot Sound Manager myself, but haven’t gotten around to it yet. So I can’t personally vouch for it yet, but all their plugins are top-notch.