Immersion starts with Sound

Dominique Dos Santos
3 min readApr 15, 2021

Looking at the game now compared to when we just started with the placeholder objects we can say without a doubt that our game has come a long way. We’ve added animations and effects like damage and explosions. We’ve used post-processing to add bloom and colour grading to make explosions look vivid and alive. But we’re missing one key ingredient in our project that will create full immersion…

Today we’ll be added sound or rather sounds to our game in the form of ambient music and event-driven sounds like when we fire our laser, when things explode and when we pick up powerups.

Background Music

In my project, I have a “Managers” object that stores all of my managers that are tied to my game. Today in that managers object I’ll be creating a new game object and calling it “AudioManager”, and in that object create another object and call it “BackgroundMusic”.

On the BackgroundMusic object, you can create a new Audio Source Component. When you first look at the component you’ll see a bunch of settings but we’ll mainly be focusing on the “AudioClip”, “Loop” and “PlayOnAwake” settings. On the Audio Clip, I’ve added our background music. Next, make sure the “Loop” and “PlayOnAwake” is ticked.

Player Laser Shooting

On the player object in the Hierarchy add an Audio Source Component. We need to check that both “PlayOnAwake” and “Loop” is deselected since we’ll be controlling the Audio Source through Code.

As you can see I have access to a serialized field on the script attached to my player. There I’ll be adding the laser firing clip and assigning it if the Audio Source is set up properly.

Explosion Sound

In an earlier article, I’ve created an explosion prefab that can be spawned whenever something needs to be destroyed. Today we’ll be building on that logic and adding another function.

Selecting the Explosion prefab, create an Audio Source Component and make sure “Loop” and “PlayOnAwake” is deselected. Next, we’ll be covering the code.

On the Explosion Prefab, we now have a serialized field where we can add the explosion clip to play.

Powerup Sound

Remember that AudioManager object we created? On that object create another child object and call it “PowerupAudio”. On the object create an Audio Source and as always check that “Loop” and“PlayOnAwake” is deselected. As covered in the Explosion Prefab, we’ll be making similar changes.

On the individual powerups, we’ll need to assign the audio clip that needs to be played.

Wrapping Up

This article covered the basics of adding audio to your game. There are best practices to follow and can add Output Mixers that you can later adjust in the options menu. But for now, this will do just fine.

--

--

Dominique Dos Santos

Self-taught Unity and C# Developer with a passion for games and the stories they tell.