0 votes

In the godot documentation for yield(), the example is given:

func _ready():

yield(countdown(), "completed") # waiting for the countdown() function to complete

func countdown():

yield(get_tree(), "idle_frame") # returns a GDScriptFunctionState object to _ready()
yield(get_tree().create_timer(1.0), "timeout")
yield(get_tree().create_timer(1.0), "timeout")
yield(get_tree().create_timer(1.0), "timeout")






Is the "Idle_frame" signal emitted immediately after _ready()? Even when ready is yielded?

Thank you for the help.

in Engine by (17 points)

1 Answer

+1 vote
Best answer

when You input a function into yield as argument, You also call it.
So countdown is called and ready is yielded. The rest of the function yields for external signals. Idle frame is emitted almost all the time, coming from underhood servers, so it unyields right after, leading to timer cascade. Last timer finishes the countdown(), so "completed" is finally triggered and ready()continues

by (8,101 points)
selected by

Thank you so much Inces! This clarifies it perfectly.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.