I am using a timer node and I need to see if it is running or not. I tried $Timer.is_active()
but it says it is a non-existent function.
Check if Timer is active?
I have not tried it myself, but the documentation says the time_left
property can be used to detect if a timer is active or not. Apparently time_left
will be zero when the timer is finished, so something like this should work:
if ($Timer.time_left > 0):
print ("Timer is active")
else:
print ("Timer is no longer active")
The timer will also send a timeout signal if you set it up.
- Edited
This probably isn't interesting to anyone, but I am doing a turn based game so I am playing around with this. You can use coroutines to wait till a function is finished and wait for a timer, which I am doing in my game:
func _ready():
yield(wait(2),"completed")
print("time is up")
func wait(amt):
$Timer.start(amt)
yield($Timer,"timeout")
I don't know how you get it to format. I pressed the code button.