The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

So i have a script where i want to store another object in a variable, a kinematicbody2d.

i cant use $... or getnode(...), because the object is not a child of the camera2d (which has this script), or maybe there is a way for $... or getnode(...) to get nodes outside of camera2d?

like unity where we make a variable that stores another gameobject in it, in godot i want a variable that stores another node.

Godot version 3.3
in Engine by (37 points)

2 Answers

0 votes
Best answer

In node paths, ".." means the parent of the current node. If the body is a sibling of the camera, the node path is "../KinematicBody2d".

by (8,550 points)
selected by

thanks, it worked for me with get_node()

0 votes

Variables can reference nodes, just make sure that you are using the correct nodepath, see

by (21 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.