It seems like no one has touched on how sound works in Unturned, so I guess I’m the one to start it.
Let’s discuss how sound works in Unturned. What the functions are for, as well as a couple of recommendations and much more.
Firstly we can start with, how to add sound effects to your object, barricade, or even item.
Everything starts from a component called ‘Audio Source’, which you can find here:
Click on ‘Add component’ and search there.
You can put the ‘Audio Source’ component in the new game object, which will allow you to move your sound source.
You’ll get a table with lots of feature settings, many of which You won’t use. (most likely)
Make sure you have ‘Spatial Blend’ enabled as 3D. Otherwise, sound will be heard no matter how far away.
Play On Awake - This means that any interactibility will start playing the sound, so leave it checked there.
Loop - This simply, means that even if the audio track of your audio ends, the audio itself will not stop, but will start again on a loop. (e.g. - Cobalt’s environment ambiance is looped.)
I’d recommend you have always ‘Linear Rolloff’ enabled instead of Logarithmic Rolloff.
Other types of rolloff, are simply not meant for Unturned and are useless. The high or low value of sound is imperceptible, but if you care about that, you can play with it.
Min distance (2 meters) is the source of the sound, and Max distance (9 meters) is the muffling, or we can call it also the echo.
The latest one is just to drag your sound file.
I’d recommend placing your sound file near to object or any prefab, it doesn’t matter where exactly it should be, but that’s how I used to. In the audio source just drag it here.
Now we’ll talk about sound files.
The most used sound file types are:
.Wav
.MP3
.Ogg
.Wav - Common file type, one of the differences is that it weighs a lot, even with good optimization.
MP3 - The most popular type, it’s much smaller than the .wav type.
.Ogg - Is probably the best option. It has a really small size than .wav and MP3 all of them combined.
The sound quality will be virtually unaffected by sound type
Load Type - If you have sounds that will be used for Envrioment Sound, (Day, Night) click on ‘Compressed in Memory’. Otherwise, it won’t work.
Streaming and Decompress On Load are the same, but ‘Decompress On Load’ is used for example, if you have an object or barricade without MasterBundling.
You can leave ‘Streaming’ in case you use MasterBundle.
Quality - If you need to reduce the size, reduce quality to 1. (It will have no difference)
Sample Rate Setting - ‘Preserve Sample Rate’ is turned by default, but if you need to make the sound quality worse so that it is more significant and there is a real difference in optimization, then choose: ‘Override Sample Rate’
The lower the number of hertz (Hz), the worse the sound becomes (the most optimal is 22,050 or default 44,100)
Choosing 22,050Hz will get rid of the error that will pop up if you have -ValidateAssets enabled (Shows errors that are not significant but can be fixed).
I recommend enabling this button so that you can hear and adjust the sound immediately in unity without launching the game.
If You think that I missed something or that there is a mistake, comment on it, thanks!
This is all the basic stuff that you should know about the sound effect. Good luck with Your projects!