|Topic was automatically imported from the old Question2Answer platform.
Hi all, I’m following the tutorial step_by_step/ui_code_a_life_bar and I’m getting confused about this part:
When you open a scene in the game, Godot creates nodes one by one,
following the order in your Scene dock, from top to bottom. GUI and
Player are not part of the same node branch. To make sure they both
exist when we access each other, we have to use the _ready function.
Godot calls _ready right after it loaded all nodes, before the game
starts. It’s the perfect function to set everything up and prepare the
But they use the function _ready of the GUI node, not those of a common parent. The GUI and players are siblings and GUI node is listed before in the scene dock.
The manual of _ready tells another thing and doesn’t mention siblings.
void _ready() virtual
Called when the node is “ready”, i.e. when both the node and its
children have entered the scene tree. If the node has children, their
_ready() callbacks get triggered first, and the parent node will receive the ready notification afterwards.
I don’t get how they’re sure the Player exists and can be referenced in his sibling GUI’s _ready function?