For the 2D games that I make it makes the most sense to me to have an Audio System that is non-positional. What this means is that the sound source is only in one place and the volume of the sound emitted from that source is the same throughout the entire game. This works well for my purposes. If you feel the need to do positional audio in 2D or espcially important in 3D you will need to utilize a different system. However, a lot of the code will be similar but you will need to do extra work to get positional audio setup in your project.
The node AudioStreamPlayer plays non-positional audio and does not require an AudioListener node.
In this project the following has been created as a automatically loaded scene: Scene: Snd_PFB and Script: Snd.cs – Sound Manager, This will be a very short name as I prefer to keep it short because it will be called frequently. instance will be just inst for the singleton for the script to further make the call shorter.
The following will be in the Sound Manager (Snd_PFB) scene.
- 1 AudioStreamPlayer – Music
- 1 AudioStreamPlayer – Voice
- 1 AudioStreamPlayer – Male
- 1 AudioStreamPlayer – Female
- 15 AudioStreamPlayer – SFX (This will allow us to play up to 15 different sound effects simultaneously.)
๐Tutorial Links ๐
Download files for this tutorial from github: https://github.com/VidyaGameMaka/godot4tutorial