0 votes

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

in Engine by (20 points)

1 Answer

0 votes
Best answer

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.

by (1,045 points)
selected by
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.