func processInput(delta): match STATES: STATES.IDLE: return STATES.MOVING: self.walkDir = 0 if STATES == STATES.WALKING or STATES == STATES.IDLE: if Input.is_action_pressed("move_right"): self.walkDir += 1 facing = false if Input.is_action_pressed("move_left"): self.walkDir -= 1 facing = true if STATES == STATES.CLIMBING: self.climbDir = 0 if Input.is_action_pressed("duck"): self.climbDir += 1 if Input.is_action_pressed("climb"): self.climbDir -= 1 STATES.WALKING: pass STATES.JUMPING: pass STATES.CLIMBING: if ladderDetect == false: velocity.y += delta * gravity if Input.is_action_just_pressed("jump"): jump() elif ladderDetect == true: velocity.y = lerp(velocity.y,0,0.1) if Input.is_action_pressed("climb"): velocity.y = -speed snap_vector = Vector2(0, 0) if Input.is_action_pressed("duck"): velocity.y = speed snap_vector = Vector2(0, 0) ladderDetect = false func handlePhysics(): currentState = STATES.CLIMBING if currentState == STATES.CLIMBING: self.velocity.y += self.climbDir * climbSpeed if currentState == STATES.WALKING or currentState == STATES.IDLE: self.velocity.x += self.walkDir * walkSpeed if currentState != STATES.CLIMBING: velocity.y = move_and_slide_with_snap(velocity, snap_vector, FLOOR_NORMAL, true, 4, FLOOR_MAX_ANGLE).y velocity.x = lerp(velocity.x,0,0.5)