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!