Why isn't all nodes' _Ready method called before _Process method?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jemapelle

I’m trying to access the ID of my player’s kinematic body (PlayerBody) by setting it in a global static NodeReference class via the PlayerBody’s _Ready function.

A child node of PlayerBody (in the scene) accesses the ID via this following declaration. (This should work like a get-property if I’m not mistaken):

private ulong _playerID => NodeReference.Player.PlayerBody.GetInstanceId();

However the PlayerBody’s _Ready method (C# for function basically) is never called before the _Process method of this child node is called, so I get a Nullreference exception thrown. Shouldn’t _Ready be called on all nodes on the scene before _Process?

Is there any other way to make sure that all nodes are initialized the way I want before _Process?

:bust_in_silhouette: Reply From: klaas

Hi,
the _ready function is called when all children of the node are initialized. So the ready call is inside out. The process function is called for every ready node. So, if the initialization takes some time other nodes will receive a process before the parent is ready.

Maybe you want to turn off processing on your child nodes until the parent signals its ready state.