Beginner Problem (Doors)

Godot 4.0

Hello! I’m fairly new to godot. Like two days so sorry if this questions seems dumb!
But I’m trying to make enterable houses and I have this system rn for entering

extends Area2D
var entered = false

func _on_body_entered(body: PhysicsBody2D):
entered = true

func _on_body_exited(body):
entered = false

func _process(delta):
if entered == true:
get_tree().change_scene_to_file(‘res://world2.tscn’)

But I want to make it so that I can set a custom position for the player in that scene(world2) and visa versa when I leave the house back to “main” scene. The script in this is on the area2d in the main scene If anyone has anyone recommendations or tips that would be very helpful! Thanks!

1 Like

For custom position you can use two approaches.
1 → use signals in Godot
2 → Use Global script in Godot

1 → If your is complex and getting bigger and bigger than you use signal instead of Global script because Global Script are complex to maintain as project succeed and become complex.
2 → If you are new and your project is small and did not have more work with maintaince than you use this approach.