Hi
func _input(event): if event.is_action_released("forward"): if (not $AccTimer.get_time_left() == 0): print('$AccTimer') else: print('hi') $AccTimer.start()
this code doesn't work properly First it enters in second logic and print "hi" Then no matter how many time elapse Its always enters in first logic and print '$AccTimer' I set Timer to "1" to "0.3" ...
Serhy if (not $AccTimer.get_time_left() == 0):
Since time_left is a float, that should be: if $AccTimer.time_left > 0.0:
if $AccTimer.time_left > 0.0:
Equality tests (==, !=) on floats are usually not reliable.
Serhy Don't forget 2 important lines:
$AccTimer.one_shot = true add_child($AccTimer)
then start your timer$AccTimer.start()
$AccTimer.start()
EDIT: oh, timer is already in node tree, so just add this line before you start timer: $AccTimer.one_shot = true
$AccTimer.one_shot = true
DaveTheCoder the same thing
func _input(event): if event.is_action_released("forward"): if ($AccTimer.time_left > 0.0): print($AccTimer.time_left ) else: print('hi') $AccTimer.start()
its like after Timer starts It never goes zero 'Null Null hi Null Null Null Null 0.116667 Null Null 0.283333 Null Null Null 0.283333 Null Null ' autorestarting?
AspireMint just swa it So I checked in the script I got error "$' unaxpected syntsx ... something I dont remember and 'add_child($AccTimer) ' either i found 'One shot' check box in the inspector and just enabled it works Thanks
Serhy Yes, sorry, my bad. I edited it. I was testing it with Timer.new() thats why I had to manually append it to node tree. But you already have instance of timer in node tree, so no need to add_child.