I have a simple setup where I want an actor to trigger an explosion sound when it is destroyed. So I added an Audio component to my BP_Enemy, and set it to my MetaSounds Source.
However, executing the destroy event does not always trigger the sound. Why is that? If I am setting this up a poor way, let me know. But I’m curious why it doesn’t always trigger.
I don’t see anything out of place but you might want to add the one-shot interface (under add interface) and connect that to “On finished” to indicate that the sound has been played.
I don’t know if this is the cause for you, but it’s worth at least looking into:
If you destroy the actor, then the sound component will be destroyed with it.
It’s probably better to configure a sound effect (not a full component,) and then spawn the sound with “play sound at location,” if you want to immediately destroy the actor.
Another option is to play the sound, but not immediately destroy the actor, but instead set its lifetime to something like 2 seconds.
If the cause is not “the actor gets immediately garbage collected, which destroys the component,” then this solution obviously won’t work
Sorry, my screenshot cut off – it does not call DestroyActor. You are correct that calling that stops the audio playback, so I removed it so I could figure out this bug.
@night_on_mars I added the UE.Source.OneShot interface and connected it to On Finished, but it still has the playback issue.
I was initially starting my level with 38 BP_Enemy actors. If I only start with 10, then each actor correctly triggers the sound. So it seems like there are problems when loading too many actors at once, or maybe there is some kind of limit to the number of wave players at a time.
Either way, reducing the number of enemies isn’t a real solution. If I want to have dozens of enemies on screen, what is the limit? where is MetaSounds running into an issue?
Use the console debug command. Hit Shift F1, press ~, enter au.3dVisualize.Enabled 1 and it will show the active sounds. Reenable the number of AIs you had and see how many you actually have active. There are other commands that might be helpful debugging at:
That’s the 4.27 page but the commands worked for me on 5.0.0 too. I haven’t tried it on my metasounds stuff but it sure showed the overages I was getting that was causing sound dropouts on the ones using sound cues. There is a limit to the number of wavs that can be playing, but I couldn’t find what it was.