Slope jittering when moving down with characterbody2d

Godot Version

4.5.stable

Question

` i am using a characterbody2d to control movement for a platforming game and when the player walks down a slope, its not smooth, rather, its jittery and looks like going down really small stairs, heres the movement part of my code

if direction and !dashing:
		velocity.x = direction * speed
	else:
		velocity.x = move_toward(velocity.x, 0, speed)

and the gravity part

if dashing:
		pass
elif rolling:
		velocity += get_gravity() * delta * ROLL_GRAVITY_MODIFIER
elif velocity.y < 0:
		velocity += get_gravity() * delta
else:
		velocity += get_gravity() * delta * FALL_MULTIPLIER
		if is_on_floor() and velocity.y > 0:
			velocity.y = 0

i have tried solutions such as set_floor_stop_on_slope() and applying gravity when on the slope, but they only work until it started moving (it slid smoothly down the slope, then i started walking and it started the jittering again), i am currently using a capsule collision shape 2d for the player

does anyone know how to fix this?
`

When on slope, don’t move horizontally with left-right controls. Move along the direction of slope instead.

how would i achieve this?

Character body knows its last collision normal. Rotate that normal by 90 degrees and you’ll have the tangent aka slope direction. Move along that direction vector instead along x axis.

thanks