I made a similar thing, so I added destination coordinates:
export(String, FILE, "*.tscn") var room_name
export(Vector2) var coordinates = Vector2(100, 100)
and when player hits the door, this happens:
Global.goto_scene(room_name, coordinates)
so instead of using change_scene, I have custom "goto_scene" function.
I'm using Global.tscn as my base scene for the game. it has Player character, and some ui elements.. this is autoloaded by Godot, and is always there no matter what level is loaded. so it let's me keep all stats, inventories etc with Player when switching levels.
(https://docs.godotengine.org/en/3.1/getting_started/step_by_step/singletons_autoload.html)
so, the level loading is implemented in Global.tscn's script file.
it's basicly just this example for documentation:
https://docs.godotengine.org/en/3.1/tutorials/io/background_loading.html#example
but I added destination variable, and then changed goto_scene and set_new_scene functions to include the coordinates... so changes look a bit like this:
var destination = Vector2(0, 0)
func goto_scene(path, coordinates):
destination = coordinates # take down the coordinates for later
loader = ResourceLoader.load_interactive(path)
[... rest of the function like in example ...]
func set_new_scene(scene_resource):
set_process(false)
current_scene = scene_resource.instance()
get_node("/root").add_child(current_scene)
get_node("Player").global_position = destination # move player to new position
it might look much trouble for simple thing, but once you are using this type of loading, it let's you do all sort of nice things.. like loading screen, or like I have forexample, different fade in/fade outs or other level switching transitions..
.b