Creating an Audio Manager in Unity

Objective: Create an Audio Manager Object and use it to play the audio clips in the VO triggers.

First we have to create a new game object called AudioManager, create a script with the same name and assign it to the audio manager. Also we are gonna have some child objects within the audio manager, those objects must have the AudioSource component (in this case i just create one child for the voice over).

The audio manager script will be a singleton so we have to create a private variable for the instance, a public property to access to this value and initialize the variable in the awake function.

In this same script I create a variable to store the Audio Source of the child object to play the voice over clips. Then we have to create a function that receives an AudioClip as a parameter, within the function we assign that clip to the audio source and then play it.

In the voice over trigger script I just use the function of the Audio Manager to play the audio.

And that’s it!!! We have a better way to play audio in our game.

--

--

--

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Kaspresso: The autotest framework that you have been looking forward to. Part I

Quick General Facts About Go

Experiments that matter

I’m new to this site, not really sure what it’s all about…kind of looks like a modernistic “tumblr”…

Alternatives to CharlesProxy and Wireshark

Python, everything is an object

Problems of iPad iOS platform app review on private API names

Go: How to unit test factory methods

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
Rusben Guzman

Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

More from Medium

Lives and Respawn System in Unity

HitBox Attack System in Unity

Light Probes in Unity

All about Sky in Unity’s HDRP