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

I have a Button inside a structure like this:
World > YSort > Player > Camera > CanvasLayer > Button
A script is attached to it and inside this script I try to reference the button by:var this_button = get_node("YSort/Player/Camera2D/CanvasLayer/CombItemButton") inside the ready() function
Whenever I start my project it crashes with the error message:
E 0:00:02.559 get
node: Node not found: YSort/Player/Camera2D/CanvasLayer/Button.
<C++ Error> Condition "!node" is true. Returned: __null
<C++ Source> scene/main/node.cpp:1381 @ get_node()
Button.gd:4 @ _ready()

Next I tried to get the button by.
gettree().getroot().find_node("Button")
Unfortunately this holds the same result and as I just started with godot I am kind of out of alternative solutions I can come up with.
I would gladly appreciate any attemt to help me out.

in Engine by (57 points)

1 Answer

+1 vote

Hi,
well ....´for the first issue ... its surely the wrong path. when both scripts are under the same parent it would be get_node("../CombItemButton")

For the second issue ... gettree().getroot().find_node("Button",true,false)
you have to enable recursive search and set owner false.

by (4,088 points)

Well I copied the path from the buttons right click in the editor. It worked for everything else, but this time it did not.

I' ll try out your suggestion. Thank you.

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.