Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | onlyJB | |
Old Version | Published before Godot 3 was released. |
Got a similar problem as this:
https://forum.godotengine.org/570/how-to-play-audio-whilst-changing-scene
In the thread somebody was able to help in IRC, the solution is not posted there tho.
I try to play sound effects via a singleton, stuffed that singleton .gd script inside of a SamplePlayer node. Even tho it is not showing any error, the “play()” function is not playing the sound.
I did load the sample into the SamplePlayer node, and if i put the node inside of my root ie, it is working proper. A debug print is also showing that the function of the singleton script is called correctly.
extends SamplePlayer
func _ready():
pass
func playSound():
play("Fireball")
print("debug SFXmgr")
Thanks in advance,
Jonathan
//edit
I was able to solve the problem with putting the “SamplePlayer” node into a “Node” and using:
SFXmgr.get_node("SamplePlayer").playSound()
to call the function.