#How do I access a node from another scene?

6 messages · Page 1 of 1 (latest)

dusk wing
#

I'm working on a gui scene with an options menu. Some options would require accessing nodes that are in the 3D scene the gui is in (like WorldEnvironment or DirectionalLight3D). I was thinking of either sending a signal to these nodes or accessing them from a path (tried but ended up freezing the program).

timid fable
#

Also.. if the script is attached to MainUI and you want to access LIGHTS...

#

The path would be

get_node("../../LIGHTS/DirectionalLight3D")

(.. goes up a level)

#

or

get_tree().current_scene.get_node("LIGHTS/DirectionLight3D")
#

You could also save a reference to the main node.

@onready var main = get_tree().current_scene

func _on_shadow_quality_item_selected():
  var sun = main.get_node("LIGHTS/DirectionalLight3D")