In the case of get_node
or $SomeNode
, a null instance error following that indeed means the node wasn't found. But the null instance
error itself only means you are trying to call a method on a variable which contains null
. For example, in obj.do_this()
, if obj
is null
, Godot cannot call do_this()
. This can happen in many other cases not involving nodes.
The debugger will stop on those null
accesses because there is no recovery possible, but the downside is that the origin of that null
may have run long before, which is not immediately obvious.
Functions that can return null
in case of an error don't stop the debugger. However, they may log an error instead, which you can see in the console log, with the call stack attached most of the time. This is what you should look for, in case you run into a null
error.
The debugger doesn't stop because the program can decide to keep running: setting a variable to null
isn't preventing GDScript from working. But trying to call a method on null
does.
That said... I wish there was a break on error
option in Godot so that the debugger actually stops the game pointing at the origin of errors as they occur, especially if the origin is a script.