Following a common file structure, we will create a
.sound file called
atm_card.insert inside your addon under
sounds/ambient/atm. The original sound file (
.mp3) will be called
atm_card.insert.wav inside the same folder. A single
.sound asset can contain multiple different sounds which will be picked from randomly on every play.
For looping sounds you will have to either place loop markers inside your sound file or compile the sound as a looping sound beforehand. To do this, you left-click once the sound in the assets browser and select the loop checkbox. This will only work with
To create the actual
.sound file, you can right click on the sound file within the assets browser and select
Create Sound Definition. You can also do this without having a sound file selected in which case a blank
.sound file will be created.
Inside the inspector you can now select your sound file and set values such as Volume, Volume Random, Pitch, Pitch Random, and Decibels/audible distance. If your sound is supposed to be a screen sound, you will also need to select the
Saving this file via ctrl + s or clicking on Full Recompile will result on a
.sound_c asset for the metadata and a
.vsnd_c file for the actual sound file, if you haven't compiled your sound already in a previous step.
To play the sound in-game, you should use one of the static methods from the
Sound class, using the name of the
.sound asset type without the extension: