Stopping a song when you leave the collision area

So, I tried this to make one song play when you enter a collision, then stopping and playing another when you leave it, but it didn´t work. The Chase song didn´t stop playing when I left and it played duplicated when I entered again.

How can I solve this?

Hey @Zander_Lawrence,

I’ve run into this issue myself before, and this solution worked well for me. I put together a small snippet for you to look at:

Audio Trigger | Epic Developer Community

Instead of using Create Sound 2D (or manually creating an Audio Component), try using Spawn Sound 2D or Spawn Sound at Location. These nodes return an Audio Component reference, which you can store in a variable.

When the player enters the collision area, spawn the sound and save the returned Audio Component reference. Then, on End Overlap, call Stop (or Fade Out for a smoother transition) on that same Audio Component.

This makes it much easier to start, stop, pause, and control the music as the player enters and leaves the trigger volume.

Hopefully that helps!

I changed it to this, but the song still doesn´t stop when the overlap ends, and still plays twice when i enter again…

@Zander_Lawrence try doing the set up i showed and see if it worked. If it does (which it did for me at least) then you can start changing it to where it fits exactly what you need.