How to spawn at specific position when changing scenes in 2D topdown?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rev7092

Im still new in godot, and im trying to change scenes using Area2D node. With my code, im able to switch scenes back and forth.

Heres my code :

extends Area2D
export(String, FILE, "*.tscn" ) var next_world

func _physics_process(_delta):
    if get_overlapping_bodies().size() > 0:

However, by using this code, the player will only appear based from where i placed his node inside of the scene, which is not what i wanted for scenes with multiple entrances. is there any way to make the player appear in a specific location in the scene using the Area2D node? (which in my case is in front of the node) Or do you need another node to do so?
Because i couldnt seem to find any guides/tutorials regarding this.

:bust_in_silhouette: Reply From: Panda_Scientist

I’m having this exact same problem and I haven’t found a real good answer to it. My solution was to put everything in the same scene far away from each other and then teleport between the areas by using doors. That kept things loaded for each area but I think the map creation would be much more easy if I could make a new scene for each area. Let me link you to my question so that we can keep each other updated.

:bust_in_silhouette: Reply From: johnygames

Your player will be a child of the new scene, will it not? I guess you could write a line of code in the _ready() function of the newly instanciated scene in which you can specify where you want the player to appear.

Alternatively, you could keep the characters position in each scene in a global variable (called singleton in Godot) and have your Aread2D nodes check it every time you change scenes.

:bust_in_silhouette: Reply From: ccpixel

I also ran into this problem recently for a top down 2D rpg and ended up making a teleport system that allows a player to move from one specific area2d to another (in any scene).

I wrote about it in more detail in a blog post here:

Maybe somebody will find it helpful.