What is the best way to make an audio manager?

SebSharperSebSharper Posts: 4Member

Hi. So I have multiple audios for my player and some other entities. The problem is that when one audio is being played and I want another audio to play with the same AudioStreamPlayer2D, it stops playing the first audio and plays the second one. I have seen that I need an audio manager to fix this behaviour. What is the best way to achieve this? A dynamic audio manager? Should it be an auto-load script?


Tags :

Comments

  • bitshift-rbitshift-r Posts: 55Member

    I've seen the recommendation more than once to use multiple AudioStreamPlayer nodes (one for each sound effect) rather than making a manager. However the official 3d fps tutorial has a section on setting up a global audio player here.

  • TwistedTwiglegTwistedTwigleg Posts: 2,663Admin

    Either method, making a global audio player or creating audio streams for each sound effect, should work fine.

    The only, minor snag with creating audio streams for each sound effect is that, depending on how you pass the sound effect file, Godot may need to load the audio from a file prior to playing the sound effect. This could possibly create a slight delay/lag as Godot loads the file from the disk, however I have not seen this myself, but it could be something to consider. Using an audio manager can work around this by loading all the needed sound effects at the start, but that’s about the only advantage, outside of just general preference.

  • CalinouCalinou Posts: 417Admin Godot Developer

    See this script for an example of a Sound singleton that adds new instances on demand.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file