Help with simple damage scripting

I was wanting to know what the best method for a simple damage system would be. Preferably done with an overlap on a hitbox (not the capsule collision) on the player. My scenario is this:

I have an enemy that chases the player. When the enemy gets within range of the player (in this case, standing in the hitbox) it should damage them. I want this damage to be loopable, I.E. loop about one hit per second or so as long as the enemy is still in the hitbox. I want to eventually have multiple damage sources, so maybe do the damage calculation in the player BP. Perhaps find a way to pass an integer or float variable from the damage instigator to the player BP when the damage script is called.

In character BP, create an On Overlap Event, from this create a Cast to (your damage instigator), if the cast is successful have a Timer start which you can use to determine how quickly Dmg is subtracted from the Character’s health. Drag off the timer data return pin and promote it to a variable.

Create an On End Overlap Event, Cast to the dmg instigator (to ensure you’re ending overlap with the specific actor), get your Timer Variable, drag off this and search for clear and invalidate timer. Now when your character escapes the Dmg volume, the Timer will stop.

You really should be using the built in damage system nodes for apply and receive damage. I recently came across these nodes and they are amazing!

Tried that already. Can’t apply damage without a triggering event. Like OnBeginOverlap which for some reason fires when leaving the hitbox as well as entering it, despite the actor only having its capsule collision set to trigger overlaps. That is why I want to do this differently as I am out of ideas for traditional overlap events.

After begin overlap use a do once node then reset on end overlap

And this is the best and easiest way to do damage, Nightshade just follow as up top by using do once node

Problem is, it still does damage when leaving the hitbox. I have it all set up, but it fires “begin overlap, end overlap” on a cycle like three or four times when leaving the hitbox.

By using the apply damage node you can def have an infinite amount of things applying damage to the player. I have no idea why it fires multiple times when leaving the hitbox. Maybe post some images of the node setup and let us at it.

Here nightshade made an easy to follow set up ( https://www.dropbox.com/s/41u83he76j…Player.7z?dl=0 ), its the third person template with Health Hud and a NPC AI character that moves then follows you if he sees you. Once close enough it applys damage every second in radius. Any questions feel free to ask and yes download is safe I promise just trying to help with easy solution…

Mike

Edit: Forgot its 4.22 most up to date version

I decided it was better to handle it in the Behavior Tree. I already have a looping task for following the player, all I need is a “distance to” with less-than/equal-to node controlling a branch. Have that branch activate the damage script when true or just finish the task when false. Now I just need to make sure the damage can only happen in sync with my attack animation. Seems unreal has animation notifiers, so that should be easy. No need for delays/timers then.

Came about this solution whilst looking for a solution to another problem, lol. Thanks for the help anyway guys.