Godot Version
4.5.1
Question
Hiya! I have a gamestate singleton in which I’ve put a gridmap reference. The idea is that levels will set this reference on _ready to the current level’s gridmap, so it can be reliably read from the same source. I have my player script also trying to read this reference on _ready, however it throws a null reference.
My current understanding is that _ready is called on parents first, so the level _ready would trigger before the player’s, however that’s either not the case, or there’s some sort of race condition with the singleton where the variable is being read before the write.
I’ve since implemented a signal in the GameState that is emitted on a setter that remedies this problem, but am still interested in learning why the original implementation failed.