How to make a death system when the npc hits the character

So i have made it so the NPC’s have a box collider in front of them, when the player enters the box trigger the npc will play there hit animation. I need it so when they hit the player about 3 times the player dies and the players death animation will play, if the player has been hit once or twice but has not been hit for a minute then it resets back to 3 again, like Outlast does its death system.

you can implement it using HP system with maximum set to 3/3

before each HP loss event, a branch should check if it’s 0/3 already, and if yes, trigger death animation.

after each HP loss event, start (restart) a 1 minute timer that is renewing HP to 3/3 when it’s finished.

You can even do it without variables. If 've understood you have a character that is healed after a minute he don’t take damage and die with 3 hits. Try this out:

EDIT: you can even not connect the death event with the Reset an set Loop true

EDIT2: it should be more correct:

Okay i got a bit lost with what you have said so i have added an image of the current blueprint that my NPC has, hope that helps

I didn’t understand when you consider the player hit.

If is when the enemy play the animation you simply have to add the bp I’ve attached in the answer then call it from the character pin in the cast node.

This could help!

Now I’ve to sleep, 1 AM here, I’ll give a watch tomorrow if you haven’t solved!

Okay thanks man, 00:00 here too I will let you know if it works

Any news? :slight_smile:

It’s almost working i have it where if the enemy hits the player it kills the player but it should be killing the layer after the enemy has been hit three times. i have some pics for you

a better solution indeed.

Use the ‘apply damage’ node and deal 1 damage after every hit to the actor it’s overlapping, on the player you must set up ‘Event AnyDamage’ and thats where you can sort out taking damage away from a health variable.

https://i.imgur.com/m3NjZqP.jpg

Just added an image with a more streamlined way of calling animations rather than repeating all those nodes you have.

If you follow your exec flow you will find that the “Hit Event” enter 3 times with no delay. The “Play Animation” node haven’t the clock symbol (unlike the delay node), that mean there’s no delay after its execution. In my advice you should add a delay and gate node after the player hit event call, each time the event overlap start use a sequence to open it and when the end overlap event start connect it to false. Use that gate to loop attacks.

Try this form:

EDIT: Obviously this form deals damage BEFORE the animation is played (even if the animation node is connected before the player hit) so when the player see the animation is too late and the damage is taken. You can, if you prefere, deal damage AFTER the animation putting the player hit event call right after the gate exit (keeping the loop). This can make your character “dodge” if he exit the overlap component before the end of the animation.

Thanks mate this looks better, however when i run the game it crashes :frowning:

Yeah that worked after a bit of tweaking!