|Topic was automatically imported from the old Question2Answer platform.
Hi, I’m new to Godot and just started doing tutorials to get used to the engine and GDScript. I’m currently following this ebook tutorial and it was working fine except for one thing. Using Godot3.2.
I accidentally cleared the script in my level scene (was a bit tired), but then attached a script again and loaded the existing one. Now it can’t find any of its own child nodes anymore. Getting null refs for all of them if I use the $ notation.
root node - Node2D named Level
- child node of type TileMap named Ground
- child node of type TileMap named Walls
- child node of type TileMap named Items
- some other child nodes, instanced scenes, etc.
Script is attached to the parent node :
onready var items = $Items
# other stuff
Debugger: attemp to call function ‘hide’ in base ‘null instance’ on a null instance
Errors : 0:00:0 get_node: Node not found: Items.
If I press F12 to continue it’ll do the same for Walls and Ground.
I’m a bit puzzled here. As far as I understood from the getting started tutorials in the Godot docs you can get the path to a child node using $node_name. Also, the script was working correctly, without errors, before accidentally removing it and then attaching it again by loading it.
I have the same thing with another script, attached to the player. All of a sudden the connected signals throw errors now. And whenever I run the project I get weird glitches, as if it can’t keep up with the 30 or so sprites on screen (but I think I read somewhere this has something to do with TileMap and Nvidia drivers)
Is there something I need to do after loading a script after accidentally clearing it?
On the surface, there’s no “trick” to re-attaching a script to a node. A screenshot of your scene tree might be helpful here.
jgodfrey | 2020-03-04 14:28