2D Characterbody movement help

Godot 4.2.2

2D Characterbody movement help

I’m trying to add a movement system for coding practice, for some reason, adding the gravity seems to remove my character’s ability to move unless it jumped and is in the air

extends CharacterBody2D

@export var speed = 175
@export var grav = 75
@export var jump = -500


	


func _physics_process(delta):
	#Gravity
	if not is_on_floor():
		velocity.y = velocity.y + grav
	
	#Jumping
	
	if Input.is_action_pressed("Jump"):
		velocity.y = jump
	
	
	
	#Movement
	if Input.is_action_pressed("Left"):
		velocity.x = -(speed)
	elif Input.is_action_pressed("Right"):
		velocity.x = (speed)
	else:
		velocity.x = 0
		
	move_and_slide()

Input.is_action_pressed(“Jump”):
velocity.y = jump

I think you need velocity.y = jump * gravity * delta.

Nothing seems wrong in your code (just parenthesis around speed variable is useless here).