35. Startup order and script lifetime
| Hook | What is available |
|---|---|
| _init | The instance is being constructed; no PCA runtime binding yet. |
| _enter_tree / _ready | Godot tree lifecycle. PCA adds the node before binding Runtime and record proxies. |
| on_global_ready | PCA’s deferred startup hook after binding a global record. |
| run / on_* event | PCA has refreshed caller context for that routed call. |
| _process / _physics_process | Only while the instance exists and processing is active. |
| _exit_tree | Cleanup as the instance leaves the tree. |
var ready_before_binding: bool = falsefunc _ready() -> void:
ready_before_binding = Runtime == nullfunc run() -> bool:
return ready_before_bindingPut PCA-dependent startup work in on_global_ready or a routed function/event. Pure local initialization can happen in _init/_ready. If you are creating something inside the current room, wait for the relevant room-load event or a direct call after the room exists.
A temporary record is queued for deletion after the awaited call completes. A Timer added to it cannot keep a repeating job alive after the function returns. For a long-lived controller, use the global checkbox and deliberate cleanup. Editing/invalidation can replace that instance.
