Play sound once

Ive got a system set up where when the enemy becomes hostile he makes a sound, the thing is it doesnt just play once, it keeps playing over and over, since the sound is about 2-3 seconds long they overlap and start before the one before it has finished, how can i make it so the sound only plays once or one at a time. heres what i have.

Thanks

[
There is a ā€œDo onceā€ node you can put just before.
then you can reset it as you want, with a custom event for example
[/QUOTE]

Thanks for the response Grot, i appreciate it, i added a do once node before the sound and it still just keeps playing lots of instances of the same sound instead of just one. Ive added a screenshot maybe you can see what ive done wrong?

1 Like

Iā€™m gonna assume this is the sound your enemy NPC makes when it is aggroed. Iā€™m guessing that you have a bunch of them getting aggroed at the same time? There a couple things you can do. first is, under attenuation settings, choose a setting, preferably an attrnuation that you custom tailored yourself. this makes the sound louder when the npc is close and soft when it is far, when customized properly. Secondly, you might want to add a random delay (plug in a random float in range into the delay pin) before the npc is aggroed, so that the sound doesnā€™t all come at the same time. youā€™ll probably add that before your show state hostile function. you might also want to put in another random float in range into the Pitch pin of the play sound node, for variation(i usually have it between .9-1.2).

if you only want 1 npc to make a sound, you can probably slip in a custom event somewhere that tells all the other npcs to shut up.

also, you might want to show the rest of your blueprint because what you showed us is just a function. thereā€™s probably something in the event graph that is causing it to loop.

If any of the previous suggestions donā€™t work, the reason for this might be that the sound file is set to looping.

Open up the sound file and in the details panel there will be a looping option.

2023 here, but in case anyone comes across this issue like I didā€¦ ā€˜Do Onceā€™ and things like ā€˜Delayā€™ donā€™t seem to work when collapsed as a function. They have to be on the main Event Graph. Iā€™m sure there are a lot of caveats to that but thatā€™s generally what I found to be the issue.

Thanks a dozen buddy. I knew the Delay doesnā€™t work anywhere but in the event graph, but didnā€™t realise that the Do once is the same and hence I got stuck with echoing voiceā€¦ Now sorted :wink: