Coroutines
Using coroutines in Godot
Info
Coroutines support in Godot Kotlin/JVM is currently Kotlin-only. Java and Scala can interoperate with Kotlin wrappers, but the coroutine helpers documented here are designed for Kotlin.
Coroutines are an opt-in feature that require an additional import in Kotlin. We follow the same logic and keep them separated from the main library.
To use it, you need to add the following to your build.gradle:
1 2 3 | |
It will automatically import our coroutine library and kotlinx.coroutines as a dependency.
That library adds a Godot specific coroutine scope and extensions to signals.
To use them, you simply need to write the following:
1 2 3 4 5 | |
1 2 | |
1 2 | |