Godot Version
Godot Engine v4.4.1.stable.steam.49a5bc7b6
Question
I am trying to make a script that is on the Rail node and i want to get a node path that is on the Level node. Is there a way to do this?
Godot Engine v4.4.1.stable.steam.49a5bc7b6
I am trying to make a script that is on the Rail node and i want to get a node path that is on the Level node. Is there a way to do this?
Scenes do not know about each other, so you cannot do that in the editor.
What you can do is, once scenes are instantiated into your running game, access the level node from the rail node. There are many ways of doing that, so you’d have to go with the one that suits your needs: for instance, if Rail is instantiated as a child of Level, you can use get_parent()
. Or you could use a global reference in code for your Level, to access it easily from anywhere.
If you need more help, feel free to share a bit more of what you’re trying to achieve.
Could you share a screenshot of your remote tree?
Accessing nodes is a runtime thing, so you need to look at what your running tree looks like, not the individual scenes.
How do i access my remote tree?
When the game is playing, in the editor, you can click on the Remote button here. That will display the running application tree state, and that is the hierarchy you want to refer to when working with node paths between scenes instances.
I believe you should be able to access your Level node in your Rail script by using get_node("/root/Node2D/Level")
.
It worked! thank you
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.