Immersion Starts with Sound

Sound is an essential component used in every entertainment industry. It creates an atmosphere that captivates the user. It establishes emotional connections, and like I’ve been saying in all my articles, this component happens to be one of the components that bring life to the game.

Objective: To have a looping background music in our game.

Every Project in Unity has the Main Camera, which by default contains an Audio Listener component, more to come on this later.

Audio Listener is a component attached to the camera by default

Let us start by creating an Audio Manager game object that will act as a placeholder for all our game sounds.

Since the Audio Manager is a placeholder for all our sound effects. Let us add a background game object to it which will contain our background sound.

We now need to add an Audio Source component to the newly created game object. The purpose of this component is to play the desired Audio Clip attached to this component.

In this case, I happen to want the background music to run on a loop, thus toggling the Loop property in the Audio Source component.

Here, Play On Awake signifies that the audio is to be played as soon as the scene loads.

Believe it or not, that’s all you require to have a looping background sound in the game.

Now, let us go back to the beginning, where we spoke about the Audio Listener component. This component works in parallel with the Audio Source component. It’s the listener that outputs the Audio Clip attached to the Audio Source to our speakers. It is important to note that each scene can only have one Audio Listener. If there are multiple sources in a scene the listener can be overwhelmed with all the sounds. Thus, the Audio Source contains various properties like Priority (importance), Volume (Loudness), Spatial Blend (if a position should be taken into consideration, for example, footsteps in games), etc. With this, you’re all set. You can now have music play as you play the game.

Thank you for reading. More to come!!!

Aspiring Game Developer with experience in the field of Machine Learning.

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