move_and_slide(vel * moveSpeed, Vector2.ZERO) for a 2D game but it works different in Godot 4 so how can I make it work

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

Complete code
func _physics_process (_delta):

vel = Vector2()
if Input.is_action_pressed(“Up”)
vel.y -= 1
facingDir = Vector2(0,-1)
(Using similar codes for other inputs)

normalize the velocity to prevent faster diagonal movement

vel = vel.normalized()

move the player

(The above mentioned code)

:bust_in_silhouette: Reply From: zhyrin

If you visit the documentation and compare move_and_slide() in 3.5 and 4.0, you’ll see that their parameter list is changed. In 4.0 the function doesn’t take any arguments, this is because all the parameters you would supply to it have been added as member variables to the class.