x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[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.

Product Version: UE 4.11
Tags:
more ▼

asked Apr 20 '16 at 03:20 PM in Bug Reports

avatar image

Zwarmapapa
105 6 8 14

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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).

more ▼

answered May 07 '16 at 12:34 PM

avatar image

Zwarmapapa
105 6 8 14

avatar image Minus_Kelvin STAFF May 09 '16 at 08:40 PM

Yes, this is what I was saying below is the issue. The fix, as detailed will work because we track how many sounds are playing on an audio component and only flag it as inactive if the number of sounds playing is 0. Thus, if you check bIsActive before destroying the component it'll prevent the issue. Not calling Play will also bypass the problem but is not an acceptable general-case solution.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Oct 07 '16 at 04:53 PM

avatar image

Minus_Kelvin STAFF
912 23 4 31

avatar image MrRabbit Feb 11 '17 at 05:04 PM

Thanks for the info Minus_Kelvin, now I know how to prevent my game music from stopping when the user decreased the in game sound volume to zero.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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():

     if (bAutoDestroy && !bIsActive)
     {
         DestroyComponent();
     }

more ▼

answered Apr 20 '16 at 04:35 PM

avatar image

Minus_Kelvin STAFF
912 23 4 31

avatar image Zwarmapapa Apr 20 '16 at 07:13 PM

If you mouse-over a SpawnSoundAttached blueprint, it still says "fire and forget".

Anyway, the bug I had was caused by calling Play on it.

In steps:

  • I spawned the sound component (with SpawnSoundAttached)

  • then I called Play on it

  • then I had a Delay node (of 1-2 seconds)

  • and then I called Stop on it

When I do this, the sound component will already be destroyed (IsValid returning false) before it reached the Stop blueprint.

I had the sound asset in a variable by the way, from the moment it was spawned, until the moment I called Stop on it. So it wasn't garbage collection that removed/destroyed it (if that is even possible with components).

Anyway, besides that, the sound will then also keep playing forever (my sound asset was a loop by the way), even though the sound component is destroyed at this point.

avatar image JoeWintergreen Oct 07 '16 at 02:23 AM

@Minus_Kelvin, The bug you fixed appears to have suffered a relapse. On 4.12 it was fine, but as of 4.13.1 if you Fade In an audio component immediately after creating it, it gets destroyed.

avatar image MrRabbit May 07 '16 at 11:07 AM

I saw the exact same problem. My workaround is to create a blueprint with an audio component and spawn those. This way the audio component doens't get auto destroyed.

This is the error note when using an audio component from the 'SpawnSoundAtLocation' node:

Error note: Error Blueprint Runtime Error: Attempted to access AudioComponent_228 via property CallFunc_SpawnSoundAtLocation_ReturnValue, but AudioComponent_228 is pending kill from function: 'ExecuteUbergraph_BP_River' from node: Set in graph: EventGraph in object: BP_River

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question