I know this is old, but I also struggled with this so thought I would post my solution.
I was able to handle this entirely in the script attached to the Player node.
In _physics_process(delta)
, I have some code to handle movement/animation and then I call move_and_collide
. The object this returns also contains the information about the object the player collided with (the door). I pass this collision object to a function like the following:
1 func handle_collision(collision):
2 if Input.is_action_pressed("interact"):
3 var col = collision.collider
4 if col.get_parent().name == "buildings":
5 var indoor_scene = "res://scenes/buildings/interiors/%sIndoor.tscn" % col.name
6 get_tree().change_scene(indoor_scene)
Line 4 should be some condition that ensures this is actually a door we are colliding with, in my case this works. Using a group may work better for you. Line 5 constructs the name of the new scene to load. I named the interior scene for all of my buildings as <building_name>Indoor.tscn
so that this scheme would work.