

Print("This doesn't make this function a coroutine. If you use await with an expression that isn't a signal nor a coroutine, the value will be returned immediately and the function won't give the control back to the caller: func no_wait(): Print("This will be printed immediately, before the user press the button.") If you're interested in a complete introduction to programming using Godot and GDScript, the unofficial Godot Tutorials YouTube channel is a good place to start. However, if you don't depend on the result, you can just call it asynchronously, which won't stop execution and won't make the current function a coroutine: func okay(): The Godot video tutorials by GDQuest, Game from Scratch and KidsCanCode are well-regarded in the community and often recommended as a gentle introduction to beginners. Var confirmed = wait_confirmation() # Will give an error.

Note that requesting a coroutine's return value without awaiting will trigger an error: func wrong(): Var confirmed = await wait_confirmation() In this case, the wait_confirmation becomes a coroutine, which means that the caller also needs to await for it: func request_confirmation(): When the signal is emitted (or the called coroutine finishes), it will resume execution from the point where it stopped.įor example, to stop execution until the user presses a button, you can do something like this: func wait_confirmation():Īwait $Button.button_up # Waits for the button_up signal from Button node. Using the await keyword with a signal or a call to a function that is also a coroutine will immediately return the control to the caller. The await keyword can be used to create coroutines that wait until a signal is emitted before continuing execution.
