autoload node not able to get other nodes??

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

tree:
-kinematicbody(autoload)
–raycast

i have a get_node() command in the kinematicbody script, but it returns error with
the node being a null instance. in other non-autoload nodes it works fine. what is happening??

:bust_in_silhouette: Reply From: boomerdev

Why are you autoloading your KinematicBody in the first place? Just instance it in the scene tree where you need it…

:bust_in_silhouette: Reply From: Inces

Read about autoload in documentation more
Autoload exists aside of the sene tree, it is a nodeless script. It can’t have children and any structure, so get_node can’t work. It also doesn’t have any way of reaching a scene tree, get_tree() returns null. However every node of your scene tree can refer to Autoload scriptwithout any knowledge of own scene tree structure, and this where it becomes truely useful