Godot Version
4.2.1
Question
Hello guys, I need some help with the doors in my game. Currently, I have a code that changes scenes after an input within the door area, however, I also need to set the player’s position when going to the other scene.
This is my code
extends Area2D
u/export_category("Next Scene")
u/export var next_position: Vector2
u/export_file var next_scene
var on_door := false
var on_scene := false
u/onready var alert := $alert as Label
func _on_body_entered(_body: Node) -> void:
_player_ref = _body
on_door = true
alert.show()
#Global.from_level = get_parent().name
#print(Global.from_level)
func _on_body_exited(_body: Node):
on_door = false
alert.hide()
func _process(delta: float) -> void:
if on_door and Input.is_action_just_pressed("interaction"):
get_tree().change_scene_to_file(next_scene)
on_scene = true
if on_scene == true:
_on_scene_changed()
func _on_scene_changed():
var alli = get_tree().get_node("Ysort/Alli")
alli.position = next_position