How do I reference a node in a different scene?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Olep

I have a player scene which is instanced in a level scene.

In the level scene I have a simple spatial node called “target_node”.

In the player script I would like to get a reference to this node so I then can get its origin. How do I do that?

I’ve tried get_node() but as I understand this is only within the scope of the player

:bust_in_silhouette: Reply From: BraindeadBZH

What you could do is add an exported var of type NodePath to the player. Then in the level scene you set the path to the target node. In the _ready function of the player you can call get_node with the NodePath var as parameter and you will get a reference to the node.