How To Stop Fmod Event Audio When Switching Levels

Hi, i’m trying to figure out how to get an event to stop playing when a player triggers a level change in game via a trigger volume. Using Blueprints in ue4.

I am triggering an ambient music track when the level loads by triggering “Play Event 2D” and selecting my event in an audio blueprint I have sitting in the level.

the player then gets to enter the next level via a portal in this level, this is achieved using a trigger volume with “on player overlap” code getting triggered.

Currently when the player does this, this level music just keeps playing. The next level loads, that levels music starts playing as well, and it all turns into a mess.

I need to stop the first level’s music during that trigger volume overlap so that i can transition into loading screen audio, and finally the next level. My problem, is that when I try to use an “Event Instance Stop” function in the logic to try and do this, I don’t know how to reference the correct Event Instance, ie the music I triggered to start when the level started. I want to reference the same ‘Level_0_Hub’ event that I started at begin play.

I notice the only “stop” audio function refers to an fmod audio component rather than an event. I’m fairly new to implementation so I’m still trying to learn what some best practices are to doing stuff like this. seems like im missing something simple but i’m having a hard time finding a way forward that works.

Any advice? Thanks in advanced.

just an update, I’m able to force the functionality of getting the audio to stop playing by calling “Unload Bank” and unloading my level bank on the overlap event. this will work for now i think, but I’d like to be able to possible fade audio out into the load screen, have load screen audio fade in, etc… As well as use the other Event Instance controls available.

what would be the best way to implement that / get the event reference in another blueprint?

You can use the Unreal Engine’s method of referencing one blueprint in another blueprint, but it would be best to visit the UE4 forums to ask on the best way to do this.

In regards to unloading a bank - this will automatically stop and unload any events assigned to this bank, however you will lose control over behaviours such as fade-out etc. if you do this way. It would be more graceful to properly call a stop on the events no longer needed in the level.

1 Like

thank you. at the time i was having a hard time getting the “stop instance event” function to work properly for me but now I think it’s doing fine. That’s still a hard cut though, if I wanted it to fade out what would be the best approach? I’ll do my own research but if you happen across this feel free to respond.

when I first wrote this I wasn’t hip to the idea of using ‘set event’ to get an event to turn into a component, giving you access to a host of more controls over it so my guess is I can find my answer in there somewhere.

i appreciate your time.

You can add an AHDSR modulator to the volume fader on the master track of the event. Then when you call stop on the event you can pass the allow fade out flag to have the event fade out.

For example: