# Regenerate health overtime and after a delay

**URL:** <https://forums.unrealengine.com/t/regenerate-health-overtime-and-after-a-delay/484396>\
**Category:** Community & Industry Discussion\
**Tags:** health, delay, unreal-engine, question\
**Created:** [June 4, 2021, 3:31am UTC](https://forums.unrealengine.com/t/regenerate-health-overtime-and-after-a-delay/484396 "2021-06-04T03:31:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Furr11](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Furr11](https://forums.unrealengine.com/u/Furr11)\
**Post date:** [June 4, 2021, 3:31am UTC](https://forums.unrealengine.com/t/regenerate-health-overtime-and-after-a-delay/484396/1 "2021-06-04T03:31:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [June 4, 2021, 6:53am UTC](https://forums.unrealengine.com/t/regenerate-health-overtime-and-after-a-delay/484396/2 "2021-06-04T06:53:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CtnDev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ctndev/32/1133321_2.png) [@CtnDev](https://forums.unrealengine.com/u/CtnDev)\
**Post date:** [June 4, 2021, 11:50am UTC](https://forums.unrealengine.com/t/regenerate-health-overtime-and-after-a-delay/484396/3 "2021-06-04T11:50:34Z")

</div>

> 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](https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScripting/ProgrammingWithCPP/UnrealArchitecture/Timers/)
