itch.io is community of indie game creators and players

Devlogs

Creating a Dynamic Music System

Beyond the Clouds
A downloadable game for Windows

Prelude:

There are multiple different ways to do dynamic music, but the two most prominent ways are track based and instrument based.

Track-based dynamic music is best when you have different versions of a song for different scenarios.
Instrument-based dynamic music is when different individual instruments are added into the music based on what's happening in game.

Track-based music is best when you have a song change its style to fit gameplay, like going from calm music to battle music, but the melody stays the same, and instrument-based music is best where many things are happening in game and you decide to give a musical identity to each, allowing you to toggle them on/off if they are present in game.

Hades is a great example of track-based dynamic music, and the Pikmin series is a great example of instrument-based dynamic music.

In this tutorial, I will showcasing how I implemented dynamic track-based music into Beyond the Clouds.

Tutorial:

Start by creating the different versions you need of the same song, I created a calm, battle, and boss version of the same song. Major things to keep in mind: all of the different versions should follow the same overall progression, have the same melodies, and be the exact same length. The length is the most important part, but keeping similar progressions and melodies will help the final result be more seamless.

Here is the music with visualizations to showcase how each is the same song in essence, but with different instruments and formatting they can be used for different situations:

Once your music is made and properly exported (remember to keep them all the same length), then we can finally go into Unity.

After this is set up, I create and attach a script called "DynamicMusic". The plan is to use this script to make the game object a singleton, allowing things to access functions inside the class without a direct reference to the object.

Then, in the Awake function, you can set the proper check to assign the instance or delete the game object, since this script should only ever be on one object at a time.

I have the object being set as a DontDestroyOnLoad to transfer between scenes and keep the music seamless, but you can also just have a dynamic manager object in each scene.

In the demo I am using developer keys to change the music, but you can call the music changes using gameplay!

This system can have added complexity and even be combined with the instrument-based dynamic music.

Download Beyond the Clouds
Leave a comment