How to save event instance reference to a new level

Hey peeps!

I’ve got this scenario and struggle trying to find the solution:
I play an event (which is set to be looping) and save the instance into a variable into my Game Instance.
Open a new level.
Event keeps playing and looping.
When I want to stop it during one of the moments on that level, I get back to my Game Instance, take the variable of this FMOD event instance, and try to stop it, with no success.
This works, if done on the same level, however.

Any ideas why that happening?
I mean, I expect UE4 to kill everything when you load a new level, but I somehow FMOD events keep playing, which probably means UE4 does not touch them? If so, how do I control them on a new level?

I would also expect it to work the way you do, although it will depend on how the Event is played.

Are you using the FMODAudioComponent or creating an Event manually in code or blueprints?

Hello Cameron!

We play the sound in Level BP, with “Play Event 2D” node.
We use “Event Instance Stop” to stop the event.

The Play Event 2D blueprint node will not stop or cleanup a looping sound.
It creates a FMOD Event Instance, not an Unreal Object which is why it does not get cleaned up when the level changes. If the AutoPlay parameter is set, the event will be started AND released immediately which then renders the returned FMODEventInstance useless for controlling it.

If you were to set AutoPlay to false, the FMODEventInstance will be valid and can be used to stop the event.

Otherwise you could use the PlayEventAttached node, this creates a FMODAudioComponent and attaches it to an Actor. This also gives you two options, Stop when Attached to Destroyed which will stop the event when the Actor this component is attached to is destroyed. And Auto Destroy, this is used to clean up the component once the Event has finished playing (non-looping).

This would be much easier to know with better documentation.
We are currently going over all of our documentation so I will make sure this is cleared up.


Thanks for your thoughts!

If you would attach an event as a component to any actor in the world, during the level loading process, it would be destroyed, as any other actor, right?
Attaching it to the Game Mode or Game Instance might work, as they are not present anywhere in the world, but in this case it’s easier to always have a component there, and simply change, play and stop events of the component through blueprints, when needed.

I like the Auto Play approach, and will try it now.

Just a reply that this method worked.