Regenerate health overtime and after a delay

Hello everyone,
I’m trying to implement a function where my player’s health will regenerate overtime, after X seconds. Is there a way to do this outside of Tick.
example: the player gets attacked and after X seconds of not getting attacked, the player’s health regenerates overtime.

thanks

Make two timers, one non-looping and one looping. You can probably use the same TimerHandle.

When you’re attacked, start the non-looping timer. If you’re attacked again, it will restart, so it will act like a retriggerable delay.

When this timer finally ticks, start the looping timer that will restore some health each tick.

If you use the same TimerHandle, I guess you won’t even have to stop the looping timer; the non-looping timer will override it.

Is there a way to do this outside of
Tick.

Why you dont want to use Tick, because of performance concerns? If yes, you can always decrease the ticking period of tick event.
On the other hand you can use TimerHandle

FTimerHandle ActiveTimerHandle
FTimerDelegate TimerDelegate;
TimerDelegate.BindUFunction(this, FName("<DepleteFunction>"));
GetWorldTimerManager().SetTimer(ActiveTimerHandle, TimerDelegate, 0.01f, true);


DepleteFunction is your function name that you can harm player.

0.01f is the ticking time of function.
You can add if clause inside of function to have delay like
if counter>5 secs start hurt

Reference about timers