How to play a song at the start of the level and after reaching the goal force the song to stop?

I have been trying to make a proper music system, I opened the level blueprint and tried to add audio component and I put the song in it, I even made a variable that serves as a reference to the song that is playing.

Now I have a song playing in the background but now I need to figure out a way to stop it, I tried with making a custom event which uses a node called Stop and I connect it to the variable of the song. After that I opened the flag actor (which its where the player has to reach in order to beat the level) and I made it clear that when the character overlaps the actor it will execute the custom event that is supposed to stop the current song, and after that is done it will play a small happy victory melody. But the first song never stopped.

Does anyone have any tips? Because I think I should re think on how to do this.

Play the song in the flag actor using ‘spawn sound 2d’. This gives you a reference you can use to stop the music when the player overlaps.

Its still doesnt work, it keeps playing. This is how my blueprint looks.

Are you getting any errors when you stop play?

Im getting none.
let me show you the whole blueprint

Try removing that ‘destroy actor’ node…

Okay I found out something, whenever the player overlaps the flag it actually makes the song more quiet instead of getting rid of it, I suspect that somehow its playing the song twice?

No wait I am retarded, it plays twice because THERE ARE TWO OF THEM IN THE LEVEL. The reason for this was because I didnt wanted to play the whole level just to see my blueprint to fail so I placed another one at the start so I could see the results quickly. Thank you a lot, I appretiate your help.

1 Like