[4.11.2] Spawn Sound Attached
"Spawn Sound Attached" is a "fire and forget" sound. Why?
The "Play Sound x" are supposed to be "fire and forget" sounds, whereas the "Spawn Sound x" are supposed to return an audio component reference to Play, Stop and Destroy it manually.
"Spawn Sound Attached" also returns an audio component reference, but yet it gets automatically destroyed after a while.
Not only that, but if the sound is a loop, the sound will never stop, it will keep on looping.
Anyway, is the name and/or functionality of "Spawn Sound Attached" incorrect or bugged?
Edit: The problem was caused by running Play on it, apparently that causes it to bug since it automatically plays when spawned.
My workaround was to not call Play on it, because it already starts playing when you spawn it.
If you call Play on an already playing spawned sound component, it will cause bugs (probably because the sound is being played twice, and after the first play it will automatically remove/destroy it, but then the second play is still going on and, with looping sounds, the sound won't ever stop).
answered May 07 '16 at 12:34 PM
This is probably because of 4.13's removal of the "play at zero volume" by default and made it as an opt-in feature for sounds. For sounds where you want it NOT to get stopped at zero-volume, make sure you enable "bVirtualizeWhenSilent" on the USoundWave. This will make it so the sound isn't immediately stopped if it plays at 0 volume.
Not 100% sure I follow what you're saying. Spawn* functions indeed return audio components and are not intended to be fire and forget.
There was a bug I fixed recently where if you immediately call FadeIn on the returned audio component of SpawnSoundAttached (or any audio component), it would destroy the original audio component and create a new one. Other Audio Component BP functions that cause the sound to replay will also have the same issue. Unfortunately, it wasn't fixed in time for 4.11.2 -- if you're having issues with this and can patch UE4, the fix is simple.
In UAudioComponent::PlaybackCompleted, add the following bool check before calling DestroyComponent():
Follow this question
Once you sign in you will be able to subscribe for any updates here