Sure! The whole process is a bit complicated as there's many moving parts, but I'll do my best.
In the pictures you can see the "rest scene" (one with orbs) and the "combat scene" (houses). When you enter an orb, a function is called that:
- Adds the combat scene (with offset) as a child of the root node
- Reparents and teleports the player to the combat scene
Orb code snippet:
func _on_encounter_orb_area_entered(area: Player) -> void:
call_deferred("_add_combat_scene", area)
var new_scene = combat_scene.instantiate()
get_tree().root.add_child(new_scene)
new_scene.global_position = Vector2(0, 0)
reparent_player(area, new_scene)
teleport_player(area, new_scene)
func reparent_player(area, new_scene):
area.reparent(new_scene.allies, true)
When teleporting from combat back to the rest scene after the fight is done, you also enter an orb with the same script (different references)
Aaaand as I was writing this, I noticed that there are 2 players in my "allies" node lol. I remember checking "remote" before and it worked, only spawned one player. Haven't touched that part of code in a week, looks like something changed, I'm gonna investigate.