Overlap Triggering Every Tick
How does one go about making Overlap not trigger every tick? To be more specific, I'm trying to have an NPC enemy follow a player, when the player gets within arm distance(Capsule component overlap) it attacks. However every time the player updates within the capsule it triggers again. What I really want is for the enemy NPC to only be able to hit the player every 2 seconds or so and only when they are in the capsule.
asked Jan 06 '17 at 03:58 PM in Blueprint Scripting
Just add a check/bool to keep track of if it attacked, and then delay.
OnBegin Overlap -> Branch (If attackedRecently) -> (False) -> attackedRecently=True -> DoWork -> Delay 2s -> attackedRecently=False OnEndOverlap -> attackedRecently=False
If the NPC can attack more than one player, you will need to make it fancier and add in an array of targets to check if it already hit as well, but the above will work for single target just fine.
answered Jan 06 '17 at 04:10 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here