extends KinematicBody2D const GRAVITY = 0.0 const WALK_SPEED = 200 var velocity = Vector2() func _physics_process(delta): velocity.y += delta * GRAVITY if Input.is_action_pressed("move_left"): velocity.x = -WALK_SPEED elif Input.is_action_pressed("move_right"): velocity.x = WALK_SPEED elif Input.is_action_pressed("move_up"): velocity.y = -WALK_SPEED elif Input.is_action_pressed("move_down"): velocity.y = WALK_SPEED else: velocity.x = 0 velocity.y = 0 # We don't need to multiply velocity by delta because "move_and_slide" already takes delta time into account. # The second parameter of "move_and_slide" is the normal pointing up. # In the case of a 2D platformer, in Godot, upward is negative y, which translates to -1 as a normal. move_and_slide(velocity, Vector2(0, -1))