“Funslingers” Devblog #21 | Immersion Starts with Sound
Music and Sound is commonly left on the back-burner when making a game, but it’s actually just as important as your game’s art or code. And as the title suggests, immersion starts with sound. So to get our game feeling AND sounding right, let’s get started putting in some tunes!
We can start simple by adding sounds to our Main Menu!
The easiest thing to put in will be our background music!
So first thing we need is our AudioSource, I’ll do this by making a quick “Audio Manager” gameobject and then create a new gameobject inside it with our Audio Source component.
From here we can simply drag our Background Music file into the AudioClip, set it to Play On Awake and Loop and now we have background music!
Now, the next thing will be sound effects for our buttons! I want our buttons to play a cool ricochet sound when they are clicked, to make my interactive menu feel even better!
To do this we’ll need to add an AudioSource to our buttons, and play them through our script whenever they are pressed.
First thing we’ll do is add our AudioSource to our Title Button, this time we don’t want it to Play On Awake or Loop.
Then, in our button script, we’ll get reference to our AudioSource Component, and call the Play method to play our ricochet sound!
I also used Random.Range to slightly adjust the pitch each time it’s played to avoid it sounding repetitive.
I’m able to apply the exact same code to our Start and Exit buttons and with that we have finished all the Audio for our Main Menu!
In the next devblog we are gonna use what we’ve learned to bring sound to the rest of our game!