No root when creating autoload

Godot Version

4.3

In my project I can’t access the autoload script, and there is no node named root in the project tree, just the normal scene nodes. I’ve created and activated one singleton named GlobalVariables following the Singletons (Autoload) tutorial but is missing. I don’t know what can be wrong.

You can try get_tree().get_root().get_node("<your auto load name>")

Accessing Singleton not from _ready() function is a common thing that will return you a null reference.
GlobalVariables should be available from any place if used in _ready()

you can access you singleton using get_node('/root/GlobalVariables')

@pennyloafers
get_root() non existent function, its just property ‘root’ of get_tree().root or Engine.get_main_loop().root

1 Like

@solver10 that should work. get_root() should still work I think.

Properties should automatically get assigned a getter and setter with the name of the property. At least in gdscript they do.

@pennyloafers tried and it really worked, well, unexpected behavior)

Thanks for your reply. I couldn’t access the singleton that way. Today restarted Godot and everything was working. Maybe a strange bug.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.