Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | abecus |
I have written a simple code.
But the problem is code does node print “waiting has completed” at all but the code works fine
extends Node
signal completed
export var n=3
func _ready() -> void:
print("waiting for 3 sec")
yield(counter(n, 2.0), "completed")
print("waiting has completed")
get_tree().quit()
func counter(n:int, wait:float):
while n>0:
print(n)
yield(get_tree().create_timer(wait), "timeout")
n-=1
emit_signal("completed")
Why does the below code does not print “waiting has completed”?
It does for me. Just copied your code into a fresh scene and got (as expected):
waiting for 3 sec
3
2
1
waiting has completed
njamster | 2020-04-08 22:49
some time it works but many time doesn’t work for me.
abecus | 2020-04-09 05:02