Switch scene and save player position

Godot Version

4.4.2

Question

Hello everyone, I apologize in advance for mistakes in the text, I am writing with the help of a translator.
In my 3d godot project there are two scenes “main world” and “interior 1”, in the main world there is a door, when approaching which I am transported to the scene “interior 1”, and in this scene there is a door that transfers back, but I appear at the standard spawn point, how to make it so that when Upon exiting the “interior 1” scene, the character appeared in the “main world” scene in front of the door to “interior 1”

Try making an autoloaded script called GlobalVariables, or whatever you want to call it, and just add one variable to it: player_spawn_position

Then you can go to your scene changing logic and add an @export var called next_spawn_position and set that variable equal to the position of where you want the player to spawn in the next scene.

Go ahead then, and before you delete the current scene and set GlobalVariables.player_spawn_position = next_spawn_position

Then go to your player script and in the _ready() function, add : global_position = GlobalVariables.player_spawn_position

Please let me know how this works for you

Thank you, you helped me a lot.

you’re welcome, glad it works for you!