I added the ClearTimer to demonstrate how you can stop a timer that you started before, for example if you only want it to run for 5 seconds. A more flexible way to use SetTimer / ClearTimer, in the context of health regeneration, is to start the timer the moment damage is taken and let the repeating regen function stop the timer itself once health is full. You can even combine this with a delay after taking damage by:
On Damage: Stop current regen timer -> Delay -> Start new regen timer that calls On Regen
On Regen: Restore some health -> If health is full, stop current regen timer
Some notes about timers and delays:
- One timer can be active on a function at a time, repeatedly setting the timer will overwrite existing timers on that function
- Similarly for delays: repeated execution of the same Delay node will overwrite the previously pending Delay
Its best to see Delay nodes like this: when entering a Delay node, a new execution thread is created that waits and then executes the rest of the graph in time parallel to the current graph.