Why is my get_node() returning null?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Victor Hernandez Can
:warning: Old Version Published before Godot 3 was released.

In this same project, in different scenes, get_node has returned me a null instance as if the node wasn’t found. Why is that? i did used the scene from another project… but i also have modified the scene inside the current project. Is there a reason? bug? workaround?Error Null Instance

:bust_in_silhouette: Reply From: eons

The scene.has_node()?

You can also check the scene tree in the Remote Inspector, is possible that you are checking it before it enters the tree.

Depends on your project, you can connect it to announce enter_tree, change a singleton var on its _ready, keep looking until has_node, et cetera.

yes, i used the has_node() and it still wont work.

EDIT: I have used the scene and script before in another project and works flawlessly. It’s not only this scene/script tho. Also a few others. I’d had to do a workaround but I’m not satisfied.

Victor Hernandez Can | 2016-10-08 03:21

Is weird…

You can try nodes to announce when they are ready or in tree to see if it is an order related thing, and show path too to check everything is ok.

It could be a bug, check on github if there is another issue related to get__node, if not and you can reproduce it on a minimal project (or you can share the problematic parts of your project), create an new issue.

If you can’t reproduce or dissappears after trying to isolate the problem, it could be a bug too but maybe not possible to identify with that information.

eons | 2016-10-08 15:46

Got it to work! I forgot that what i had to add as singleton was the scene and not the script! .-. things like this makes me feel really really dumb. Thanks a lot though! really appreciated!

Victor Hernandez Can | 2016-10-08 16:41

:bust_in_silhouette: Reply From: Victor Hernandez Can

Found my own error. Instead of setting as autoload the scene, i was setting the script file instead.

:bust_in_silhouette: Reply From: FeralBytes

The Remote scene may not be the same as the local scene. It is best to debug this to know for sure. So from the menus “Debug” > Check “Deploy with Remote Debug”.
Run your program again. Return to the Godot editor via + . On the scene manager switch from “Local” to “Remote”, and check the hierarchy of nodes now. Helped me a ton.