O'Reilly logo

Unity 4.x Cookbook by Matt Smith, Chico Queiroz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Making a dynamic soundtrack

Dynamic soundtracks are the ones that change according to what is happening to the player in the game, musically reflecting that place or moment of the character's adventure. In this recipe, we will implement a soundtrack that changes when the player reaches specific targets. Also, we will have the option of fading the sound in and out.

Getting ready

For this recipe, we have prepared a basic level and some soundtrack audio files in .ogg format. They are contained inside the Unity package named DynamicSoundtrack, which can be found in the 0423_06_06 folder.

How to do it...

To make a dynamic soundtrack, follow these steps:

  1. Import the DynamicSoundtrack package into your Unity project. Also, import the 00_main, 01_achievement ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required