Click, Bang & Boom! — A guide to playing sound effects in Unity

Continuing on the previous article we are going to play and trigger a sound effect.

Adding a sound effect to an object makes the game feel much more immersive. So for our next step, we are going to add a sound effect to our explosions.

We start by creating a script for our audio manager in which we take an audio clip as a parameter. The audio manager is a singleton so we can easily access it and call our function from other scripts.

Next, we need to add our explosion audio clip as a reference in our explosion script and call it when our game object becomes active.

Next, we need to add our sound effects as a group and make them louder than our background music in the audio mixer.

Now we can add our sound effect audio source by adding an empty game object as a child to our audio manager and add an audio source component to it.

Remember to assign the audio mixer group in the audio source, assign the explosion clip in the explosion prefab and assign the sound effects audio source game object to the audio manager.

And there we go a simple yet effective way to play sound effects.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store