Using a trigger to stop a spawn sound at location loop

Hi there,

I have basically set up a PA system where a sound cue loop of an alarm is playing at several different speaker locations throughout the level which is triggered when the player spawns. I then want the player to be able to switch off the loop once they are in a trigger box and press E. I have included a screenshot of how i have set this up, i just cannot work out how to turn off the loop. Any help would be greatly appreciated!

Hi there. I’ve had a bit of a go at this. My solution isn’t the best but it provides a basic premise and hopefully answers the question. I’ve used the First Person Shooter template as the basis of the solution.

  1. I placed several triggers that are noted as Speaker 1, 2, 3 and 4 respectively. These are used for the locations of the music/sound being spawned.

  2. I created a Speaker Control Panel Actor, which stores the Audio Component references that come out of the [Spawn Sound At Location function][1]. This way these audio components can be accessed later to turn the sound off. The Stop All Sounds function loops through each of the audio components stored and tells them to stop playing their sounds. By default, the Sound At Location function tells the audio component to destroy itself when the sound has been stopped, so once all of the sounds have been stopped, I clear the array of audio components so we can no longer reference dead objects.

  1. I created a trigger for the control panel which could be referenced by the level blueprint. This trigger was used to tell if the player could turn off the sound or not. Once the player enters the trigger, they’re able to turn off the sound which is emitted from the speakers. I also threw in an input capture for E so that when E is pressed and the trigger has been entered, the sound will be turned off. Don’t worry about the Control Panel UI reference there; that’s just to show the instructions when the player walks into the trigger.

  1. To add the sounds to the Speaker Control Panel Actor, I add them after they have been spawned:

The yellow lines indicate the respective locations of the speakers.

If you would like to see the basic implementation, I’ve placed it on up on [github][5]. (To get to it, if you open up the project and go into the folder named “Spawn Sound Loop Question” and open up the map in the map folder, it should get you there.)

Hi there Hightype!

Thankyou for your response, i did have a look through your solution and it was helpful thanks! However i have just discovered a slightly simpler way of doing it in case any one else would like to emulate what i have done. The idea could do with some refinement but the concept works. Apologies if the blueprint is a bit cramped i tried to fit it all into one screenshot.

Basically I:

  • Created a trigger on top of the character spawn point so the alarm would trigger as the character would spawn. I then referenced this in the level blueprint and connected it to a DoOnce node which then connected to a sequencer.
  • This sequencer then activated each spawn sound at location node used, each one of these nodes is attached to the speaker location taken from the level.
  • I then set up a variable so when the player pressed E next to a console in the level it would set the alarm console as true.
  • The spawn sound location nodes where then connected to a branch with the variable set as the alarm console check. If true the alarm sound will stop if false then after a delay of 0.2 seconds it will check again to see if the console had been activated.

I hope this is clear!

No problem; glad I could help!