This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Every time im trying to do something with a node (like $node.global_position or something like that) i get error with null instance (invalid get index 'global position' (on base:'null instance'). I looked in the interned and found what this error may occur when script is unable to get the node. Am i doing something wrong and how do i fix that?

Godot version 3.5
in Engine by (68 points)

1 Answer

0 votes

"null instance" is what you get from get_node() when you give it an invalid path.

If you're getting this error, it means that you are not using a valid path to get the node you want. It's impossible to tell you exactly what you're doing wrong because you haven't showed your node setup or where in your code you're trying to access the node. Regardless, you must give the correct node path in order to get the node.

It's important to understand how node paths work. If you're familiar with the directory structure of your operating system (Windows, MacOS, Linux), they work in exactly the same way.

This link may help you with understanding how to get a node:
http://kidscancode.org/godot_recipes/3.x/basics/getting_nodes/

by (22,191 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.