0 votes

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

in Engine by (82 points)

3 Answers

+1 vote
Best answer

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

by (82 points)
selected by
+1 vote

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 entertree, change a singleton var on its _ready, keep looking until hasnode, et cetera.

by (7,922 points)

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.

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.

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!

0 votes

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.

by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.