Mobile Game Progression
Adding Sound and Music to our Game
Time to add some sound effects to our game along with some subtle background music to set the mood of the game.
The background music is important and must be chosen correctly because the music is complementary to our gameplay style. It help sets the mood and flow of the game. During the brainstorm session there was several things that I wanted:
- All game Scenes will have background Music
- The Main Menu is going to have an aggressive beat that urges the player to play
- The Credits scene since it is going to appear at the end game is going to be soft and serene to tone down the game.
- The actual game will project a quiet and mysterious vibe.
Implementing The Audio:
Once you have imported your music files into Unity we are going to first start with the Main Menu scene. Create an new empty game object and name it “Audio Manager”. This object would house everything related to sound and music.
Since the Main Menu only has one background music and one sound effect, we will only need two empty game objects to contain the Audio source.
Inside the empty game object, we will add an “Audio Source” component. For the background music, we are going to keep the “Play on Awake” checked. For the “Click Sound” we are going to do the same procedure but this time we are going to uncheck the “Play on Awake”. This is because we only want to sound to be active when the button is pushed.
To trigger the audio file for the On Click event on the buttons, simply create a new On Click function and drag the Click Sound game object into the slot. Then for the parameter select AudioSource > Play().
For the game scene we are going to do the same setup for the background music. We are going to create a new Audio Manager which has a Audio Source component with the “Play on Awake” and “Loop” set to active then drag in the song of choice.
In the next article we will focus heavily on implementing sound effects for our player and enemies.