Gravity stops working when multiplying by delta

Godot Version

v4.3.stable.official.77dcf97d8

Question

hello, I am a complete beginner.
I am having trouble with my movement code, for the most part it is fine, however when I try to multiply velocity for gravity by delta it messes with it
the gravity stops working, it only moves the character down a very small amount when moving side to side. It also messes with the velocity of the jumping.

extends CharacterBody2D

var jump_count = 0
var double_jump = 2

const ACCELERATION = 50
const FRICTION = 90
const SPEED = 800
const JUMP_VELOCITY = -1700

var GRAVITY = 110

const WALL_JUMP_PUSH = 180
var WALL_SLIDE_GRAVITY = 130
var is_wall_sliding = false 


func _physics_process(delta):
	
	var input_dir: Vector2 = input()
	
	if input_dir != Vector2.ZERO:
		accelerate(input_dir)
	else:
		add_friction()
	player_movement()
	jump(delta)
	wall_slide(delta)
	jump_height()
	
func input() -> Vector2:
	var input_dir = Vector2.ZERO
	
	input_dir.x = Input.get_axis("left", "right")
	input_dir = input_dir.normalized()
	return input_dir
	
func accelerate(direction):
	velocity = velocity.move_toward(SPEED * direction, ACCELERATION)

func add_friction():
	velocity = velocity.move_toward(Vector2.ZERO, FRICTION)

func player_movement():
	move_and_slide()
	

func jump(delta):
	velocity.y += GRAVITY 
	if velocity.y > 0 and jump_count == 0:
		jump_count = 1
	if Input.is_action_just_pressed("jump"):
		print(jump_count)
		if jump_count < double_jump:
			velocity.y = JUMP_VELOCITY 
			jump_count += 1


	if is_on_floor():
		jump_count = 0
	
	if is_on_wall() and Input.is_action_pressed("right") and Input.is_action_just_pressed("jump") and not is_on_floor():
		velocity.y = JUMP_VELOCITY
		velocity.x = -WALL_JUMP_PUSH
	if is_on_wall() and Input.is_action_pressed("left") and Input.is_action_just_pressed("jump") and not is_on_floor():
		velocity.y = JUMP_VELOCITY
		velocity.x = WALL_JUMP_PUSH 
	
func wall_slide(delta):
	if is_on_floor():
		WALL_SLIDE_GRAVITY = 110


	if is_on_wall() and not is_on_floor():
		if Input.is_action_pressed("left") or Input.is_action_pressed("right"):
			is_wall_sliding = true
		else:
			is_wall_sliding = false
	else:
		is_wall_sliding = false
	if is_wall_sliding:
		velocity.y += (WALL_SLIDE_GRAVITY * delta)
		velocity.y = min(velocity.y, WALL_SLIDE_GRAVITY)

	if Input.is_action_pressed("down"):
		WALL_SLIDE_GRAVITY += 20
		print("sliding")
	if Input.is_action_just_released("down"):
		WALL_SLIDE_GRAVITY = 130
		
		
func jump_height():
	if Input.is_action_just_released("jump") and velocity.y < 0 and jump_count < 1:
		velocity.y = 50 

This is weird no ? I mean, If you are on the ground, not moving, your velocity = (0,0,0) but when you enter this function you put velocity.y to a positive value

so it will always consider this condition true on the floor and I think you don’t want this behaviour.

I think you probably want you GRAVITY to be a negative value or keep it positive and do velocity.y -= GRAVITY.

Also I’d said that if gravity worked fine without multiplying it with delata and nota fter, it might be because the value isn’t high enough ?

Let me know if I’m on the right way to help you ^^

Doesn’t positive y move something down while negative y moves something upwards
I tried changing to negative and that caused gravity to reverse.

I also tried setting the gravity to a higher number when multiplying by delta
this is the number where it fell somewhat normally

var GRAVITY = 6000

I’m not sure if the gravity is usually supposed to be this high
will it cause problems being this high?

also the gravity seems to be determined by my left and right movement, it gets faster when I move left and right, and is much slower when I let it fall down without moving

thank you for the help it seems to be working now
I also changed these pieces of code
to make it work better

velocity += Vector2(0, GRAVITY)
	velocity.x = move_toward(velocity.x, SPEED * direction.x, ACCELERATION)
	
func add_friction():
	velocity.x = move_toward(velocity.x, 0, FRICTION)