KinematicBody2D Ramp Glitching

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Athsmooth

For some reason, when I go over a ramp the first time, everything works. But after a few times of going over, the ramp doesn’t work and my player glitches. Here is my code:

velocity.y += delta * GRAVITY

if Input.is_action_pressed("ui_left"):
	if is_on_floor():
		velocity.x = -WALK_SPEED
	else:
		velocity.x = -WALK_SPEED / 2
elif Input.is_action_pressed("ui_right"):
	if is_on_floor():
		velocity.x = WALK_SPEED
	else:
		velocity.x = WALK_SPEED / 2
elif is_on_floor():
	velocity.x = 0

move_and_slide(velocity, Vector2(0, -1))