Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
Easy to use Coroutine functionality in Godot 4, such as resume() or join()
Godot4-Coroutines
Easy to use Coroutine functionality in Godot 4
Resume
The Resume pattern is used to stop the execution in a subfunction, which will wait for its caller to call
resume()
for it to continue where it had stopped. See ResumeExample.tscn
.
- The resumable function must take a
Coroutine
as first argument. To stop execution, it must await on theCoroutine
'sresume_signal
signal. - Create a Coroutine using
var coroutine := Coroutine.new()
- Call the resumable function using
coroutine.resumable_call(my_resumable_function)
- Note: use
bind
to add arguments to the call:coroutine.resumable_call(my_resumable_function.bind(arg1, arg2))
- Execution in
my_resumable_function()
will stop onawait coroutine.resume_signal
- Resume the execution using
coroutine.resume()
- Once
my_resumable_function()
has finished,coroutine.is_completed
is set totrue
and the return value ofmy_resumable_function()
is incoroutine.return_value
Join
Join is used to launch the execution of multiple functions, then waiting for them all to finish before continuing execution. See JoinExample.tscn
.
- Create a Coroutine using
var coroutine := Coroutine.new()
- Add a function you want to differ awaiting on using
coroutine.add_future(my_joinable_function)
- When all functions are added, use
await coroutine.join()
to wait for them all to finish
Easy to use Coroutine functionality in Godot 4, such as resume() or join()
Reviews
Quick Information
Easy to use Coroutine functionality in Godot 4, such as resume() or join()