Play sound at location with parameter

Hi,

Today I discover why my sound can’t play multiply times. It’s looks like, when you are using Audio Component Reference UE treats it like ambient sound and can’t play multiply times. This is a shame because when you are using Play Sound At Location (which can play multiply times) you can’t use sound parameters. Am I right ?

Is is possible to change Audio Component to play multiply times at the same moment without stoping previous sound. Or Play Sound At Location with parameters ?

I can spawn new Audio Component with parameters wherever I want to play sound but this is an ugly way.

Cheers !

Hey Roshondas,

What you are reporting is expected as replication is not handled when using the Play at Location. These are considered ‘Fire and forget’ sounds which also contain no audio component.

Whenever you get an audio component involved and reference that component to play a particular sound, that component is going to reinitilize and replicate itself and replay the sounds contain within the Sound Cue/Wave.

You can either use the Play at Location to have the same sound played on top of one another, or create multiple audio components and call each to play. You might be able to go into code and change how the audio component handles replication, but as it stands what you are reporting is expected.

We have done a serious overhaul of the Audio engine for 4.16 so a lot of the ways sounds work now, will be improved and changed with the next engine release. Keep a lookout for those and continue testing sound issues as we will need all the ears we can get to continue to improve our audio engine.

Thank you,

Andrew Hurley

Hey Andrew, not sure what his question has to do with replication, which is a multiplayer thing, right?

Basically the fundamental issue is confusion over what the purpose of an audio component is. Audio components are a “handle” to a single playing sound. Technically since a sound cue can play multiple sounds if you use a mixer node, the audio component can be a handle to multiple play sound instances (i.e. "stat soundwaves shows you the sound source instances playing).

If you don’t need a handle, you can use the PlaySound static BP functions. If you need a handle either add an audio component to your scene component or actor or whatever or spawn one using the SpawnSound static BP functions.

Reasons why you need a handle include:

  • You want a sound to be attached to another actor so it moves with the actor
  • You want to change the parameters on a sound once it’s playing for dynamic volume or pitch changes
  • You want to play a looping sound and want to be able to stop it.
  • You want to control precisely when a sound finishes playing (maybe it’s a long-duration one-shot but you want to be able to stop it at any point).

Leting an audio component be a handle to multiple sounds creates a serious issue with sound management. If I call “SetPitch” on an audio component that’s a handle to multiple sounds, what do I do – do I set it on all of them? Alternatively, playing another sound on the same audio component might default to orphaning the old sound (i.e. detaching) and just using the audio component on the new sound. But that would cause serious bugs, orphaned loops, etc.

Just use multiple audio components if you need multiple handles for multiple sounds.