extends CharacterBody2D @export var speed = 200 var toCalculate = position var distanceTo = 0 var active = false func get_input(): if Input.is_action_pressed("escape"): get_tree().change_scene_to_file("res://scenes/menu/main.tscn") var input_direction = Input.get_vector("left", "right", "up", "down") velocity = input_direction * speed func _physics_process(delta): if active: get_input() move_and_slide() distanceTo = position.distance_to(toCalculate) if distanceTo > 500 and active: $Label1.visible = false $Label2.visible = false $Label3.visible = false active = false $camera.enabled = false get_parent().next() func start(): $camera.enabled = true active = true toCalculate = position $Label1.visible = true $Label2.visible = true $Label3.visible = true func loadJSON(id): var save_path = str("user://player_data"+str(id)+".json") print(save_path) if not FileAccess.file_exists(save_path): return var file_access = FileAccess.open(save_path, FileAccess.READ) var json_string = file_access.get_line() file_access.close() var json = JSON.new() var error = json.parse(json_string) if error: print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line ", json.get_error_line()) return var data:Dictionary = json.data $Label1.text = str("Name: "+data.get("name")) $Label2.text = str("HP: "+data.get("hp")) $Label3.text = str("Level: "+data.get("level"))