Post tutorial RSS How to change the background music? (one soundtrack)

A simple tutorial on how to change the soundtrack / background music played in Car Tutorial project.

Posted by on - Basic Sound Effects

In Car Tutorial project, it's quite simple.
1. Open CarEdu (/CarTutorial) project, find and expand directory in Project tab:
/Sounds/Sound/
So you see CarTutorialSong.mp3 file
2. Find your .mp3 file, then drag it into the directory where CarTutorialSong is
3. Untick 3D Sound, tick Decompress On Load, click Apply
4. Select Car object (the main parent object, not its child parts), scroll down to Sound Controller (Script), then change Background Music by clicking the circle next to the name, and set it to your mp3 file.

That's pretty all. This tutorial shows only how to replace one soundtrack with another. If you know more about JavaScript and coding, to make the game play more soundtracks you'll probably need to check this piece of code below:

backgroundMusic = gameObject.AddComponent(AudioSource);
backgroundMusic.loop = true;
backgroundMusic.playOnAwake = true;
backgroundMusic.clip = BackgroundMusic;
backgroundMusic.maxDistance = BackgroundMusicVolume;
backgroundMusic.minDistance = BackgroundMusicVolume;
backgroundMusic.volume = BackgroundMusicVolume;

157-163 lines, SoundController.js in Scripts/JavaScripts (note the backgroundMusic variable declaration in the line #50).

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.