I am trying to add sound effect to my UI buttons but as I test something it play and something it don’t. I think because something before the sound fully played the scene changed that might be the problem but I don’t know how to solve this.
I am sharing you my codes and a example video below
Your audio is getting cut-off because you are changing the scene so it’s getting deleted before it can finish playing the audio. There are multiple ways of fixing this:
Which one is the best and effeciant way ? I think the autoload one is best because I can use that in other scenes too but still I don’t know how to implement it can you please explain it further
yes, @mrcdk mentioned it already… the sound you trigger is cleared by calling change_scene. the flood scene is erased and the sound is erased with it
and isn’t it useless to call a new scene every time in such a simple menu? it would be better for you to have one scene where you could simply hide and unhide given screens in the GUI. then the sound playback would not be a problem because you are always moving in one scene
or
instantiate the given scenes in a specific node in which you will also have the AudioStreamPlayer you will call
Well if you have all your elements in one scene, and you disable/hide the buttons you don’t need (and change the text, essentially what the other comment said), then you can simply connect the buttons’ signals to one script that controls what is currently shown.