Home and Learn: Games Programming Course


Adding Sound Effects (SFX) to Unity Game Characters

Our zombie from previous lessons is a bit on the quite side, a stealth zombie, as it were. Let's get him moaning!

We only need to add an audio source to our zombie, and then download a few zombie sounds. First, we can download some sounds.

There's a great zombie sound pack here on the Unity Asset Store (Window > Asset Store). It's by professional game developer Catastic. Here's the link:

Zombie Sound Pack - Free Version

Add the Asset and you'll see the Package Manager open in Unity. Download the sound files and import them into your project. Your Project area should look like this:

Unity project folder showing a zombie sound pack downloaded

Have a look in the VO folder to see more sound files. We'll use the one called Zombie001_Attack_A_003. Remember, you can hear what it sounds like by selecting a file and clicking the play button in the Inspector on the right:

How to preview a sound file in Unity

Now we need to add an Audio Source to the zombie.

Select your zombie in the Unity Hierarchy on the left. With your zombie selected, go to the Inspector on the right. Click the Add Component button and add an Audio Source:

Adding an Audio Source to a game object in Unity

In the screenshot below, notice that there is a slot for an Audio Resource. You can either drag and drop an audio file from your sounds folder into the Audio Resource slot. Or you can click the small circle indicated by the red arrow. From the dialog box that appears, select your sound:

Unity Inspector showing the Audio Resource property highlighted

The Select Audio resource dialog box

Before playing your game, make sure to check Play on Awake and Loop:

Unity Inspector showing the Play on Awake and Loop properties highlighted for an Audio Resource

When you run your game now, your zombie should be a little less stealthy. You'll hear him walking along, grunting with whatever sound you selected. (You'll still hear him grunting, even when you kill him and he disppears from the scene. We'll fix this later.)

Now let's get the zombie to follow the player.

<--Back to the Unity 3D Course Contents Page

 


Email us: enquiry at homeandlearn.co.uk