0 votes

Hello everybody,
I am new to Godot and am struggling with soundeffect playback.
I am aware that a AudioStreamPlayer can only play a single sound at a time.

I came up with a script object that pre-loads 3 AudioStreamPlayer and tries to reuse them by checking if there is a AudioStreamPlayer that is currently not playing a sound, if there is no such player a new one is created.

When debugging everything looks fine. A player is found, the sound does exist, the play()-function does not crash… but there is no sound.

My assumption is that the AudioStreamPlayer does not play any sounds as long as it is not attached to any scene in the current room… so, maybe I have to attach the AudioStreamPlayers to the object that actually should play the sound?

I bet there is a pretty simple answer to this.
Thx in advance :)

in Engine by (12 points)

1 Answer

0 votes

Like nearly any node in Godot, AudioStreamPlayer needs to be added to the scene tree to have an effect.

PS: You can use an autoload like this one to create AudioStreamPlayer nodes from anywhere that are freed automatically when the sound is done playing.

by (12,825 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.