+2 votes

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.

asked Jul 8 in Engine by Rev7092 (18 points)

2 Answers

0 votes

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.


answered Jul 8 by Panda_Scientist (25 points)
0 votes

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.

answered Jul 8 by johnygames (1,576 points)
edited Jul 8 by johnygames
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.