Playing SFX and/or one more music file parallel with background music

Shirted-VanesShirted-Vanes Posts: 12Member

I have an AudioStreamPlayer and it works well - my background music is playing without issues.
For now I wanna add a sound effect when something is triggered (e.g. pick up an item). How can I play it in my ASP?

Should I just create new node and load my sound effects there? What if I wanna play like 5-10 audio files at the same time - should be there 5-10 ASP nodes? I just wanna make sure if there is an easier way to do this stuff like... idk maybe using buses in "Audio" tab.
Thanks in advance.


Tags :

Best Answer

  • CalinouCalinou Posts: 256
    Accepted Answer

    What if I wanna play like 5-10 audio files at the same time - should be there 5-10 ASP nodes?

    Yes, you will need to create one AudioStreamPlayer node per sound instance. Make sure to remove them using queue_free() once they're done playing to avoid bloating the scene tree unnecessarily. This can be done by connecting their playback_finished signal to the queue_free method. (I'm not sure about the exact signal name, as I'm on mobile right now.)

Answers

  • CalinouCalinou Posts: 256Admin Godot Developer
    Accepted Answer

    What if I wanna play like 5-10 audio files at the same time - should be there 5-10 ASP nodes?

    Yes, you will need to create one AudioStreamPlayer node per sound instance. Make sure to remove them using queue_free() once they're done playing to avoid bloating the scene tree unnecessarily. This can be done by connecting their playback_finished signal to the queue_free method. (I'm not sure about the exact signal name, as I'm on mobile right now.)

Sign In or Register to comment.