Hello,
I have a widget that plays a sound 2D in its blueprint. How do I stop this sound? Another method that would suit my needs is stopping every sound.
Thank you for reading.
Hello,
I have a widget that plays a sound 2D in its blueprint. How do I stop this sound? Another method that would suit my needs is stopping every sound.
Thank you for reading.
You first need to keep a reference to the sound that is playing. In other words don’t call “Play 2D Sound” because that doesn’t return a reference. Instead, call Spawn Sound 2D which does return a sound reference.
When you have a sound reference you have two options to turn it off/on.
By call SetActive and passing in a true/false as the “New Active” parameter or by calling ToggleActive which will activate the sound if it’s already activated or deactivate it if it’s not.
Did this solve your issue TalkingIsGreat?
I want my music to loop, and I have a button that switches the value on a Boolean variable. How do I make it so that the music stops but still loops when I turn it back on again?
What you can do is create a new Sound Cue. In the Content Browser, right click and go to Sounds > Sound Cue.
Give the Sound Cue blueprint a name and then open it.
Right click the graph and add a new Wave Player node. Select the Wave Player node and in the details panel select your Wave sound file to play and check the “Looping” checkbox.
Update your Spawn Sound 2D and change the source file from the audio file to your new Sound Cue class.
Thank you.
thanx for the first one, it solved my landmine being stepped on, making a little fsssh sound and then stops, when you walk further then bang!
great! thanx
Not sure if this was available when the sound cue answer was written but you can now loop audio without making a sound cue. Just double-click on the sound wave asset to edit Detail properties and check Looping.
Thanks
Thanks
Thank you, I used this to stop a song when hitting “back” on a widget.
Hello, I tried this blueprint and didn’t get the performance I wanted. My goal is is to play the sound completely “once” on a grab. Another grab should not restart the sound until the sound has completely played. How would you do that for a 3 minute song for example?