Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | gtpark0904 |
I have the following code in a node and have a timer node named “Monster_Timer” as its child node
func _on_Monster_Timer_timeout():
print(timer)
if timer == 1:
timer = 0
timer += $Monster_Timer.wait_time
the wait time is 0.05
When I run the code, the number keeps rising even when it reaches 1.
What’s wrong with the code??
================================
I solved the issue
First, the code works fine when the wait time is 0.5
So I changed the code into this:
if int(timer) == 1:
timer = 0
I guess when the wait time gets small, something goes off
Another valid way to fix this would be:
if timer >= 1:
# do stuff
jgodfrey | 2022-08-04 13:40