Immersion Starts with Sound
Objective: Adding background music to your game.
With the addition of sound, you game will jump from a silent film to the golden age of cinema! This will immediately set the atmosphere for your game, and further immerse the player as they travel through the world you have created.
To begin, if you select the main camera, you will see a component called audio listener. This acts like a microphone and transmutes any audio clips you add to your game through your computer speakers.
For background music simply create a controller to manage all the games audio. Create an empty object and label it, Audio_Manager.
For this object to play audio it must have the component audio source.
With audio source we can add a clip, loop, and adjust said clip as we see fit.
Since we are making background music, it will be better to use a less generalized audio source by creating another empty object child to the Audio.Manager.
Add component audio source.
Drag your imported audio file and drop it into the audio clip field on the audio source. Unity will support .aif, .wav, .mp3, and .ogg.
Activate play on awake and loop.
When you start the game, the music will automatically start and loop until the game is over. Now you can add music to your game. Don’t be afraid to experiment with your game and I’ll see you in the next tutorial.