Jumping not working

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lolzsicka (school)

this is what i have for physics process function:

velocity = move_and_slide_with_snap(velocity, Vector2.UP)
velocity.x = 0
velocity.y += gravity * delta

if Input.is_action_pressed("left"):
	velocity.x -= speed 
if Input.is_action_pressed("right"):
	velocity.x += speed

if Input.is_action_just_pressed("jump"):
	if is_on_floor():
		velocity.y = jump_speed

for some reason the jump doesnt work and i cant seem to figure it out.

:bust_in_silhouette: Reply From: Ertain

The line velocity = move_and_slide_with_snap(velocity, Vector2.UP) should be at the bottom of that code.