extends State export (NodePath) var idle_node export (NodePath) var move_node onready var idle_state: State = get_node(idle_node) onready var move_state: State = get_node(move_node) func enter() -> void: .enter() animations.frame = 6 func process_input(_event: InputEvent) -> State: move_component.get_movement_direction() return null func process_physics(delta: float) -> State: parent.velocity.y += gravity * delta parent.velocity.x = move_component.desired_movement_vector.x * move_speed parent.velocity = parent.move_and_slide(parent.velocity, Vector2(0, -1)) # if parent.velocity.x != 0.0: # parent.direction.x = parent.velocity.x if parent.velocity.x > 0: parent.direction.x = 1 elif parent.velocity.x < 0: parent.direction.x = -1 if move_component.flipped_sprite == true: animations.flip_h = parent.direction.x > 0 else: animations.flip_h = parent.direction.x < 0 if parent.is_on_floor(): if parent.velocity.x == 0: return move_state return idle_state return null