Music in a trigger box with background music

Hi, I’ve set up a scene where there’s ambient background music, and when the player enters an upper room, he enters into a trigger box that plays a different song.

The problem is that when the player leaves the trigger box, the triggered music keeps playing instead of stopping and letting the ambient music continue.

I’ve found two videos on YouTube that show this setup, but in both cases they do the same process (the second audio keeps on playing, not the ambiental sound) and in both videos, people are asking in the comments how to make the ambient music continue after leaving the trigger box -no reply-. So I assume there’s no video that actually explains how to do that properly.

In one comment I read:
“The best could be to create 2 audios on the level. And in the trigger zone, create 2 variables to define these audios. Then when you enter, set Audio 1 volume from 1 to 0 and Pause it, and set Audio 2 volume from 0 to 1 and then Play. And on exit, do the reverse…”

But I have no idea if that’s really the correct way. Since I’m a beginner, I still learn by watching and can’t really reason through these kinds of setups. So I’d like to know if somebody could tell me how to fix it.

Hey there @Unediense! If this project is smaller in scope, this way is fine for a beginner, but can introduce issues at scale or if audio is handled by multiple objects around the same time. However “best practices” wise, usually this is all handled inside the Audio Manager to keep things nice DRY and decoupled. Doing it your way, you should be able to just do the reverse when the actor leaves the area:

Though as you mentioned, if you want the original song to keep playing from where it was instead of anew, you’d have to handle the volume crossfade yourself.

1 Like

Hi, thanks a lot for your time and your help!

I have done this,

It’s wrong but I don’t know , I think I still have to put more effort to understand blueprints, because I know that if I remove musicplayer from my estructure, it gives me an error, but don’t know how to solve.
Very grateful, though! I’m going to keep on reading your answer to figure it out.