- Edited
Serhy i'm not fond of pre-baked timers in godot. they can be a bit unwieldy on logic.
What I do is create a manual timer out of frames and use a simple bool logic to stop it. This is also useful as we can get increments slightly faster than a half second. The math isn't as clean as the seconds-based Godot timer but it moves by frame so it's smooth. Surely a "brute force" solution but it works for me.
So something like:
const var _timerRefill = 100 ## your max value here
export var _timerValue : int = 100 ## export total value to editor
export var _timerRate : float = 0.5 ## export rate of total drain
var _isRunning = false ## bool logic to begin
func _process(_delta):
if _timerValue > 0: ## if it's running, drain the timer
if _isRunning:
_timerValue-=_timerRate
else:
_isRunning = false ## flip the bool off and reset when done
_timerValue = _timerRefill
## do something
~~~~