Coroutines
Enable coroutine support in build.gradle.kts, then reload the Gradle project in IntelliJ IDEA:
| build.gradle.kts | |
|---|---|
1 2 3 | |
Node.launch starts on Godot's main thread and cancels its child coroutines when the node exits the scene tree. Start it in _ready() or later, while the node is inside the tree. The body runs immediately, until it first suspends, so a coroutine that never suspends finishes before launch returns; see the reference's "Threads" section before emitting signals that other scripts await.
The following Player method waits for the next healthChanged emission. It can be invoked from _ready().
1 2 3 4 5 6 7 | |
These coroutine helpers are Kotlin-only. Java and Scala use normal signal connections instead.
See the coroutine reference for frame waits, flows, thread switching, and a complete encounter example.