This is a tutorial for a free add-on that I made because there seems to be no easy way of changing music during gameplay. For example, a normal nice soundtrack plays, but enemies attack you, then it should switch to some action music, once the area is cleared, it should revert to the main track again.
So in this tutorial I will explain how to set up and use the add-on.
1. Download Music Manager and extract the necessary files into the Bonus folder.
2. Put the BP_Music_Manager actor anywhere into the level
3. Open the BP_Music_Manager actor and set the soundtracks for Main and Action music
3. While there, click on the Action music and disable Auto-Activate
4. That was actually the hardest part, you can now change the tracks on the fly from literally anywhere, as it adds new Blueprint nodes to work with
For the sake of “why not”, let’s make the enemy start the Action music when it attacks you and stop it when you kill it.
5. Open any enemy base class and add a collision sphere (size is 512) and make the collision settings of the sphere look like shown in the picture bellow, then right click on it and OnEventOverlap (Sphere) add the following:
Basically this will activate the Action music when the player overlaps with the sphere.
6. To stop it and bring back the Main music, still on that same enemy go to EventAnyDamage, and at the very end, right before it gets destroyed, change the music again, like this
Where you will place the change soundtrack nodes is up to you (overlap with something, event in the level, interacted with something, etc.
You can create child classes from it and have one for like a forest map, snow map, etc.
You can also add more types to the enum and copy/paste the Action logic to make new types.
If you need more than 2 songs, special thanks to rabassa from Discord for this solution: