Godot Version
4.3.stable.mono
Don’t name the root node of your scene ‘Game’
I could not find this explained anywhere else (either it does not exist as explicit information or my google powers are lame).
The docs say the following about the node names:
(Node — Godot Engine (stable) documentation in English)
“The name of the node. This name must be unique among the siblings (other child nodes from the same parent). When set to an existing sibling’s name, the node is automatically renamed.”
So, here it is.
In the scene you are running, if your top-level node is called ‘Game’, the hierarchy tree breaks.
My Case:
I am restarting a small project (as an easier way to refactor and declutter it) and immediately I got a problem.
Here is the three of the old version and then the new one:
The scene in both cases is the one that is run by default.
For the sake of clarity and newness, I decided to change the main node from ‘Map’ to ‘Game’.
I immediately ran into a problem.
I have a global script, designed to set up everything.
First thing in _ready() is a refererence to the TileMap.
In the new project is just returned null for tile_map.
After quite a while, comparing everything piece by piece between the old (working) project and the new one, I found this - see the same trees (old and then new) viewed as Remote in runtime:
It turns out that when you run (at least in debug), Godot creates a ‘Game’ node and that causes conflict of names. As the node in question is the main in the hierarchy, it has a sibling with the same name, so it gets renamed to ‘@Node2D@3’.
So you need to use a different name.
I hope that this may help someone at some point. Remote/Local are available options only at runtime, so I was stuck with the problem for a good three hours myself, before I noticed then and checked what’s happening under Remote.
P.S.
For the sake of completeness, I tried leaving the main node ‘Game’, then finding it by it’s name after renaming (‘@Node2D@3’) and it works. I just had to check.