How to make an event effectively occur once every X seconds?

I am creating a game where an AI runs towards the player and damages them on collision.
I am handling the collision in my enemy BP using the OnComponentBeginOverlap event. Whenever a player is detected on the damaging component, a damage interface message is sent to the player. However, sometimes this event is triggered many times in a few tenths of a second (probably due to movement interactions).

I would like to limit the interval between calls to this damage interface message. I am currently doing the following but I think there is a better way:

As you can see, I am creating a timer for a dummy event that does nothing, which makes me think there is certainly a better way to do this. The behavior I’m looking for is something like a retriggerable delay, but I need the damage to occur before it and not after.

I may also want to tick damage to the player while they remain in the damaging collision component belonging to the enemy, but I don’t see any event for that, only on begin and end overlap.

Any help would be greatly appreciated!

What about something like

Oh wait, you mean timed damage without another collision?..

( untested ).

4 Likes

Thank you so much, this is perfect!

1 Like

Delay are not a good habit so… not sure

?

A DELAY is just a node, like the BRANCH is a node. If you use DELAYS as a band-aid, then, sure, it can be “bad”, because then you’ll have mistimed events firing and messy loops.

But this is a clean usage of the node, not to mention that the DO_ONCE really clamps down on reiteration.