Godot - Implement delay processing with await
Code example for implementing delay processing with await and create_timer()
in GDScript.
It is possible to implement delay processing using await and create_timer()
.
This code has the following features:
- Specify delay time in seconds as argument of create_timer()
- Delay all subsequent processes
await get_tree().create_timer(3.0).timeout
print("await")
When used in iterative processing, increasing the delay time may yield the expected result.
for i in enemies:
await get_tree().create_timer(i * 3).timeout
print(i)