Event triggering multiple times, only need to trigger once

Unreal Engine 5 Blueprints: First Person Shooter (FPS) is the course I’m on, I’m going back through and adding new features to the project. Specifically having the enemy drone play a sound when it’s aggroed by the player, this occurs when the player gets too close to the drone or when they shoot the drone.

When no sound plays there’s no issue because the drone aggros and chases you as intended. But when I have a sound play the Play Sound at Location function triggers every time that I shoot the drone, and with an automatic weapon that happens a lot. This results in the sound file playing over and over and getting louder each time it overlaps.

So, what I’m wondering is how to limit the sound file to only play one time when the drone is initially aggroed. Any help is greatly appreciated!

Add a boolean variable such as Has Been Triggered and set it initially to False. Then on your aggro event, branch on it if it is True or False. If it’s False, set it to True and then do your logic. If it’s False, then don’t play the sound.

I’ll give that a whirl and let you know if it works or not. Thanks for the suggestion!

That worked! Thanks so much!

There’s also a DoOnce node that might also achieve the same effect.

1 Like

I’ll look into that as well. It might be more efficient or helpful in other areas. Thanks for the suggestion!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms