How to use "await" in godot 4.0 ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By linyangqi

As it’s already changed from “yield” , don’t really know how to use “await” now…

(still the help page hasn’t had the introduction…)

You mean You used yield() before and await() is different ? If only name of method has changed I can help

Inces | 2022-02-18 14:14

right, the usage of “await” is not the same as “yield”

linyangqi | 2022-02-19 01:12

:bust_in_silhouette: Reply From: Christian Baune

Like this:

await get_tree().create_timer(1).timeout

Where “timeout” is the signal you are waiting for.

yield could be used to stop a method, and then continue where it left off. can you not do that with await? await seems like it will just retrigger the same method starting from the beginning.

WolframR | 2022-07-17 05:20

FYI, this example is a bit misleading - waiting for 1000 waits for 1000 seconds! You want to wait for 1.0 (one second) instead.

nightblade9 | 2023-03-21 16:15

Thanks, I corrected accordingly!

Christian Baune | 2023-03-21 16:21

2 Likes