SOVEREIGN MOON PRESENTS…

How to Add Background Music into a Unity 3D Game Kit Game

In this tutorial we’ll learn how to add background music into a Unity or 3D Game Kit game. Adding music to your scenes is easy. Simply follow these steps.¬†

Sovereign Moon Studios is dedicated to helping game enthusiasts bring their creative visions to life by teaching them how to make a video game from scratch without having to know how to code or draw. ⚡

How to Add Background Music into Your Game (No Coding Required).

Today, Sovereign Moon Studios, the makers of your favorite¬†NoCode game development course, are excited to bring you a new tutorial that will walk you through the steps of adding background music into your Unity 3D Game Kit game. Adding music into your game’s scenes is easy and my goal for this tutorial is to help you setup background music for your game in about 5 minutes

Let’s jump in!

Introduction:

If you’re new to Unity or 3D Game Kit, at some point you’re going to want to learn how to add music into your game scene. Music can really help you support the emotion you’re trying to convey within your scene. Luckily, within Unity and 3D Game Kit, the process of adding music is really easy.¬†

How to Add Music

To add music into your game, you simply need two new elements. You need an audio listener and an audio source. 

Audio listener: Think of an audio listener as the element within your game that hears your music. Essentially, this is the part of your world that captures the sounds that are being produced in your game. For example, if your character walks past a portal, that portal might emit a gentle buzzing or electric sound. Something within your game needs to hear those sounds. In most cases, game developers will add their audio listener to their camera. This is because in most games the camera follows the character around and therefore the sounds that are emitted will be picked up and registered by the camera which shares the perspective of the player. Therefore, all game sounds will appear to surround the character from their proper position within 3D space. 

Audio source: An audio source is simply object within your game that is producing or emitting sound. That sound could be a sound effect, folly, atmosphere, room tone, dialoge or music. 

Now, all we need to do is add an audio listener and audio source to our Unity game. 

adding music to unity

The first thing we need to do is we need to add an audio listener. Within 3D Game Kit, the audio listener is already added to our game camera. If you go into the hierarchy tab and search for “camera” and then select “camera brain” (see image above) you will notice that the camera is already equipped with an audio listener.

adding music 3d game kit

If you do not have this component added to your game yet, you can simply scroll to the bottom of the inspector tab and click “add component” and search for “audio listener”.

unity audio listener

Next, all we need to do is add our music into the game

Adding the Source of the Sound

The source of the game music can be anything. Obviously, if you had a music emitting object like a radio, television or sound system, you would want to associate your game’s music with those object. Remember, because our audio listener is connected to our camera, the audio will change depending on our character’s position in relation to those objects. For example, in 3D space, the sound will appear more distant if our character is futher away from those objects, and louder if the character is closer.

However, in todays tutorial we want to focus on adding background scene music into the game that remains consistent throughout the entire game. In order to do this, we need to set our character as the sound source. Essentially, our character will be emitting the sound of the music and our camera will be listening to the sound.

Within Unity’s 3d Game Kit, we need to go to our heierachy tab and search for our character. In our case we need to search for “Ellen” since this is our main character’s name. However, if you’re not using 3D Game Kit you’ll need to search for your character’s name.

Once Ellen is selected, we can go over into the inspector tab. Currently there is no audio source added to her character so we need to do that now. To add an audio source, simply scroll to the bottom of the inspector tab and click on “add component”. Search for and select “audio source”.

3d game kit music

Once you have added an audio source to the player we can start setting up our background music.

Adding Background Music into Unity

All we have left to do is modify a few settings in the audio source component section.

The first thing we need to do is add our clip. Unity supports many audio file formats including mp3, WAV, MPEG, OGG Vorbis, AIFF, MOD, IT, S3M and XM.

You’ll also want to ensure that “loop” is selected so the music continues to loop in the background while your character is in the game world.

You’ll also want to select “play on awake” so that the music begins as soon as your character spawns.

Lastly, you’ll want to adjust your volume and set your music to play in 2D or 3D space. For this tutorial, we’re not adding any directionality to our source so we’ll set it to 2D space. Your audio source section should look something like this.

how to add music to Unity 3d game kit

Once we’ve completed all of these steps we can play our game and the music will be added to our scene.

Conclusion

So¬† that’s it. I hope you’ve enjoyed this tutorial.

Remember,¬†if you’re trying to take your n0-code game development skills to the next level, consider enrolling in our n0-code game development course where you’ll learn how to make breathtaking video games without having to know how to code or how to draw.

Sovereign Moon Studios is dedicated to helping game enthusiasts bring their creative visions to life without having to know how to code or draw. Our NoCode game development course teaches indie game devs how to build breathtaking games from scratch. ⚡

Want to Make Video Games?

Do you love game design? So do we! For this reason, we created a no-code video game development course that walks you through the process of bringing your game visions to life without needing to know how to program and without having to be an artist. We will teach you how to bring your game to life in our 4 hour 36 module no-code game development course.