Godot Version
4.2.1
Question
I’m working on scene transitions. So the Area for the transition is in World1, the target position is in World2.
Currently in the “SceneTransition.gd” I’m using
@export_file() var sceneFilePath
@export var targetPlayerPosition: String
Later I load the scene, instantiate it, add the player-node and set its position to the position of the node under NodePath(targetPlayerPosition)
.
Ideally I’d like to select the node path directly in the editor in World2.tscn. But since the SceneTransition-node is inside World1, I only get the selection dialog for the nodes in World1.
Is there a way to get a selection of the nodes in other scenes than the scene the node is currently via the Inspector?
Nodepaths are relative within the tree, so there is no relative path to the nodes from your World1 to World2 if ther are separate scenes.
You can have a script in World2 instead where you set the path in the inspector and then you’ll be able to access that from World1 after you load your reference to World2.
What do you mean by “script in World2”?
I’ll try to clarify what I’m doing.
The way it works right now is that the “SceneTransition” node in World1 is triggered and loads the scene for World2.
Then it looks for the node under NodePath(targetPlayerPosition)
in World2, gets that position and sets the players position to that.
That’s working fine and there’s no extra script needed in World2, just the node for the position.
What I’m wondering is if it is at all possible to select a node in a different scene from the Inspector via @export
vars. Right now it doesn’t seem like it.
In the end it’s just a matter of convenience, since the transitions are working.
I haven’t tried Advanced Exports yet, maybe then I could load the tree under the scene selected in sceneFilePath
whenever that changes.
Okay I think now I understood what you mean.
Your idea works if I have one entrance position per World and just get that position from the World when I load it.
But what I want are variable amounts of entry/exit positions for any given possible transition point from another world.
So there are multiple ways to get from World1 to World2 and every way puts the player in a different spot in World2.
PS:
Now that I think of it I could also define a dictionary of points in World2 and get those points based on the key that I set in the transition in World1. But then I still have to check the correct string key manually and don’t get in-editor editing like I would have if I could select NodePaths in World2 from World1.