This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

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

Shirted-VanesShirted-Vanes Posts: 13Member

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: 376
    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: 376Admin 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.)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.