Attempt to call function 'get_node' in base 'null instance' on a null instance

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

Hello, I have a perfectly working project.

I needed to add a scene to this project and I needed to test it as a single scene: so, basically, my idea was to work on it, then click on Run Current Scene to test if anything was working fine.

Problem is, when I do that, I get an error:

"Attempt to call function 'get_node' in base 'null instance' on a null instance"

The node in question is related to an autoloaded Game.gd file where I stored the game logic.

Is there any way to test my single scene? Could you tell me how?

(the project works fine if I click Run Project, instead)

Could you manually instance the autoload class if it’s null?

SteveSmith | 2023-05-04 11:47

The autoload is not simply a class, it is a file full of useful functions and manages the state of the game.

What I don’t understand is: my new scene is completely empty (no code, nor references to other code or scenes: it is completely unrelated to anything).

I’d like to test it as it was a completely different thing. I don’t understand why there’s a “run current scene” button if I can’t use it. :slight_smile:

Alternatively, I could build my “component” in a blank project and then import it in the main project.

OTGOD | 2023-05-04 12:06

Could my issue be related to this? https://github.com/godotengine/godot/issues/75998

OTGOD | 2023-05-04 12:10

So is the null node a (null) instance of Game.gd?

SteveSmith | 2023-05-04 12:26

Exactly (an @onready property). Even if I test a completely different scene with no code, etc., for no apparent reason Godot searches for things that are in the main scene (Game and main scene are related)

OTGOD | 2023-05-04 12:42