Jump not working, I see the problem but don't know how to fix it.

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

extends KinematicBody2D

export (int) var speed = 1200
export (int) var jump_speed = -1800
export (int) var gravity = 4000

var velocity = Vector2.ZERO

func get_input():
velocity.x = 0
if Input.is_action_pressed(“walk_right”):
velocity.x += speed
if Input.is_action_pressed(“walk_left”):
velocity.x -= speed

func _physics_process(delta):
velocity.y += gravity * delta
velocity = move_and_slide(velocity, Vector2.UP)
if Input.is_action_just_pressed(“jump”):
if is_on_floor():
velocity.y = jump_speed

Please, elaborate your question and format the code using these code tags (without spacing): < code > < /code >

betauer | 2023-06-16 12:08

Indeed, if you see the problem then elaborate on what the problem is to help us help you

godot_dev_ | 2023-06-16 13:06

:bust_in_silhouette: Reply From: SnapCracklins

Excuse me, but if I’m not mistaken isn’t moving a sprite up supposed to be MINUS in 2d?

velocity.y -= gravity * delta