Godot Version
v4.3.stable.steam
Question
And so I’m making a game in which the player can move between rooms (each room is a separate scene)
For me it all works like this: The door is an Area2D that checks whether a player has entered it and if he has entered, the variable is changed, and if he has left, it is changed to an empty set
I also have a function “input” which in if will check the variable whether the player is standing at the door and whether he pressed the button “USE” and if YES, then the animation of the screen fading is played and upon completion there is a transition to a new scene, but if at the time of playing the animation you press the button again after the animation is completed an error will occur
@ _input(): Parameter “data.tree” is null.
<C++ Source> scene/main/node.h:446 @ get_tree()
MainKoridor.gd:18 @ _input()
my cod :
extends Node2D
var door_in_klass : String = ""
func _ready() -> void:
$Player.position = Global.save_position_player
func _input(_event: InputEvent) -> void:
if door_in_klass == "rus" and Input.is_action_just_pressed("use"):
Global.save_position_player = $Player.position
$Player/UI/Tranzit_scene.show()
$Player/UI/Tranzit_scene/AnimationPlayer.play("perehod_up")
await $Player/UI/Tranzit_scene/AnimationPlayer.animation_finished
get_tree().change_scene_to_file("res://Scene/lvls/klass_rus.tscn")
func _on_door_rus_body_entered(_body: Node2D) -> void:
door_in_klass = "rus"
func _on_door_rus_body_exited(_body: Node2D) -> void:
door_in_klass = ""
I understand that perhaps this is a crutch, but please tell me how best to do this