I’m trying to display a cooldown timer in godot, in my other project the same exact code works perfectly, as a matter of fact I imported the same exact scene into the new project and the imported scene works.
but the scenere where i copied and pasted this function, the one from the new project… well in that one the code doesn’t work because remaining cooldown is always 0 and always not 0 at the same time.
func updateLabel(label: Label, cooldown: float, current_time: float, last_time: float) -> void:
var elapsed_time: float = current_time - last_time
var remaining_cooldown: float = max(0.0, cooldown - elapsed_time)
print("remaining_cooldown:", remaining_cooldown)
if remaining_cooldown!= 0:
label.text = str(remaining_cooldown)
else:
label.text = ""
New contributor
Xenophile is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.