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

Both scene1 and scene2 are inside a main scene3.
Why won't the "Button" node from scene1 script hide (interact with) scene2?

-scene3 node
--scene1 node(contains "Button")
--scene2 node(contains "Node2d/Sprite")

extends Panel

func _on_button_pressed():

func _ready():

Edit: Okay I've since realized that the scenes weren't instanced properly. The following worked:

-scene3 main node
--scene1 node
---scene2 node

extends Panel

var block

func _on_button_pressed():
    block = load("res://scene2node.tscn").instance()

func _ready():
in Engine by (22 points)
edited by

2 Answers

+1 vote
Best answer

where is the "block" node?
you don't have to start with get_tree()

you can get a reference in various ways.
one of way is using get_parent()
if "block" node is located at parent of your current Panel,
you can get it with get_parent().get_node("block")

or just simply do get_node("../block") with relative path.

by (9,800 points)
selected by
+1 vote

At a glance, it could be because you're using get_tree().get_root().get_node("block") in one case and get_node("block") in another. Those aren't the same path.

Other than that, you should probably provide more information. What does your node tree look like?

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.