Play(Spawn)SoundAtLocation problem

Greetings everyone. I’ve recently started working (well, “toying” is a more suitable term) with UE4 and faced some problems concerning the usage of PlaySound nodes in Blueprint scripting.

My idea was to create a SphereTrigger template, which would sublty play a selected sound whenever a player is within the trigger’s boundaries(the sound volume would depend on the distance between the center of a trigger and a player).

I am not quite familiar with the topic, so I decided to have two variables for this blueprint for the SphereTrigger - the sound to play and audio-component responsible for playing the sound. In the beginning the audio-component will be created via SpawnSoundAtALocation. With every tick it checks if anyone is overlapping the trigger and starts playing the sound (by the way, selected concurrency settings disallow multiple sounds being played).
The main problem is that whenever I use a character to enter the SphereTrigger and the required nodes are fired, the sound is only playing in the EventGraph (or any other window like the one with the tutorials) in the BlueprintEditor when I focus on it as on a main window and not in the main 3D viewport.
What can I possibly do to deal with this problem? I am sorry for the prolonged introduction and thanks for the help in the advance.

You don’t need to do any of that :wink:

You can just put an ambient sound actor there and set the attenuation. You make the attenuation in the content browser.

Also, you’re killing the sound right after you’ve spawned it:


End overlap with what actor?
You should trigger adjust volume when needed, play sound only once. Not every tick.
Attenuation needs to be added too (if you still want to spawn sound at location).

Sorry for the misleading:

I thought this event is fired whenever something overlaps the entire trigger (sphere).
I wasn’t familiar with ambient sound actors and decided to keep a variable (AudioComponent), generated by SpawnSoundAtLocation in the BeginPlay Event to play it whenever the player enters the trigger (the condition is checked each frame). The attenuation settings are already included (as I think) in the SpawnSoundLocation(DefaultAmbient).

In my prev. message I tried to explain why I stop the sound in the beginnning (in brief: I thought I could reuse the variable generated by SpawnSoundAtLocation again each time the player entered the trigger).
So am I right now to think that once I stop the sound of AudioComponent there is no way to play it again?
In the meantime I will try to do the thing with the ambient sound actor. Thanks for the hint.

There’s a lot of different ways of playing and stopping sounds. From memory, I recall if you stop after spawning, that’s it.

Anyway, you can definitely do this with an ambient sound actor with attenuation configured.

Thank you and other people for helping me. Now I will try to follow your advice.

1 Like

These are very good learning courses on sound design: