How to Stop "Play Sound 2D" Blueprint

How to Stop “Play Sound 2D” Blueprint

Use SpawnSound2D instead. This way you’ll receive a ref to the audioComponent. Now you can manually play and stop the sound as you please :slight_smile:

@Featuriing its working
but can i do like this is it affect performance?
Can you show me on the BluePrint?

2 Likes

I would actually recommend to store a reference to your AudioComponent in a variable (“MyAudioComp” in the example).
This way you can stop the sound on EndOverlap and destroy the audio component. This way things are properly cleaned up.

3 Likes

You can btw. even use AudioComp->FadeIn and AudioComp->FadeOut to make the sound start and stop smoothly :+1:

@Featuriing How to use that please show it on Blueprint

The most elegant way in this case is to re-use the AudioComponent of your sound.
We are just creating a new one in case there is none existing yet. Then we FadeIn on beginOverlap. OnEndOverlap we are just fading out but keeping the sound alive to reuse it on the next BeginOverlap by fading in again.

2 Likes