How to regenerate life after some timewithout taking damage

Well, I used a system of life and armor, which when I enter a “Box Collision” I take damage … I was able to create another system that causes that if I leave this “Box Collision” for 5 seconds, only life regenerates slowly … But how do I always REGENERATE life when I do not take damage? For example in the future I will add projectiles and weapons in my game. I will not copy the whole system for every weapon or thing that takes life. Need help…
Here are some prints to help me.
Oh and if you have some suggestions to improve this system I would apreciate
PS: Both health and armor variables default value are set to 1.0

You’ll need to use tick to compare how long it’s been since you’ve last been damaged.

You can use this BP, it assumes the health is in a range of 0 - 100 though.

Basically the changes would be, whenever that pawn walks into your pain volume you call the HurtMe event. This is a static 15 damage though. You would want to have the Event have a float input of how much damage you want it to do.

16bit I can look stupid butvim new on unreal engine and im only 13… The thing is that i dont understand how you calculate how manu time sincera i didnt get damaged… Help plz

Well its specifically this part that calculates how long it’s been since you’ve been hurt.

223334-screenshot-10.png

If the time remaining until regen can happen is not zero. Then each frame (a tick event) subtract how long we have to wait.

First you have to understand what tick is. Tick is called each frame and produces a delta number (World Delta Seconds), this is how long it took to render that frame of gameplay. For a game that runs at 60 frames per second, tick is called 60 times. We use delta seconds to subtract from the number because frames vary how long they take to render. But each frame we subtract a how long it took to render that frame from the time remaining, and once it hits zero, we allow the hp to regen.

Ok thx 16bit and thanks amaster Gebjeter, i will try understanding all this… If I have any issue i ask here if you would answer

I have a problem, why you subtract Time until regen and Get world deltaseconds? Thanks :wink: