Godot Version
4.2.2
Question
In my game, I currently have a scene named “PlayerGrenade”.
The node tree is as follows.
As the screenshot shows, there are currently two AudioStreamPlayer2D’s in this scene.
- One for the countdown beeping, (Has a set duration. The Audio player stops playing when an enemy steps on the grenade hitbox.)
- And the other for when it explodes. (Plays after either the grenade countdown ends or if an enemy steps on the grenade hitbox. )
In the game, after pressing the relevant button, the player throws 3 grenades at once. (This is three instances of the PlayerGrenade scene.)
Therefore, this will create 3 of each ASP. (AudioStreamPlayer)
Which is quite loud.
My requirement is to only play one of each ASP when the 3 grenades are instantiated into the Game Level scene. (One Grenade beep ASP and one Grenade Detonation ASP.)
And if one grenade explodes before the complete countdown time has passed, the next ASP should take over and play the remainder of the sound effect.
I’ve thought of using an ASP as a singleton and calling it when needed. But I’m having a bit of a difficult time implementing it properly.
Any assistance on this would be much appreciated. Whether with implementing this via Singletons or any other method.
Thanks in Advance!