extends Node2D const FOLLOW_SPEED = 30 @onready var current_node: OverworldPath = $OverworldPath var follows_next_path = false var follows_previous_path = false func _process(delta): var path_direction = "" if Input.is_action_just_pressed("ui_up"): path_direction = "up" if Input.is_action_just_pressed("ui_down"): path_direction = "down" if Input.is_action_just_pressed("ui_left"): path_direction = "left" if Input.is_action_just_pressed("ui_right"): path_direction = "right" if current_node.next_direction.has(path_direction): follows_next_path = true follows_previous_path = false if current_node.progress > 0.0 and current_node.previous_direction.has(path_direction): follows_next_path = false follows_previous_path = true elif current_node.progress == 0.0 and current_node.previous_path and current_node.previous_path.previous_direction.has(path_direction): current_node = current_node.previous_path follows_next_path = false follows_previous_path = true if follows_next_path: if current_node.progress < 1.0: current_node.progress += delta $AnimatedSprite2D.position = current_node.current_position else: follows_next_path = false if current_node.next_path: current_node = current_node.next_path if follows_previous_path: if current_node.progress > 0.0: current_node.progress -= delta $AnimatedSprite2D.position = current_node.current_position else: follows_previous_path = false