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.
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.
Just a note, you really shouldn’t attach anything that involved to On Tick. Events you won’t need to take place more than say 50 or 100 times / second should be set up with Timers.
I’ve tried using Event ActorBeginOverlap but it doesn’t seem to work in this case. This event triggers only one frame until the pawn “exits” another actor and doesn’t solve the problem of pushing pawn. In my testing, it also only triggers when actors actually overlap (overlap behavior is defined as Collision Presets in mesh component) and by default, it’s pushing instead of overlapping.
If we are using Event Tick the pawn is going to be checked and pushed every frame thus solving the problem