Setting player position when changing scene

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

hello im new to godot and im trying to make an 2d rpg my player is able to change scenes area1d and collision2d nodes which are placed over my door scene instances i would like to know how i can set the players position so she doesnt enter and end up in the middle of the room id also like to play the door animation when “e” is pressed

extends Area2D

var entered = false

func _on_body_entered(body):
entered= true

func _on_body_exited(body):
entered= false

func _physics_process (delta):
if entered == true:
if Input.is_action_just_pressed(“e”):
get_tree().change_scene_to_file(“res://Scenes/PlayerRoom.tscn”)

:bust_in_silhouette: Reply From: aidave

There are many ways, consider using Marker2D to be Spawn points, then set the players global position to the spawn point global position that you want.

thank you, i dont mean to be a bother but how do i go about getting the players global position and then setting it to the spawn position im very new to godot

venam | 2023-03-17 13:07

You would do something like:

$Player.global_position = $Marker2D.global_position

aidave | 2023-03-17 14:28

1 Like