Move_and_slide function is not working in my code! (Godot 4)

Godot Version

4

Question

(I just started using godot :smile:)

So I wanted to make my char look at my mouse and move towards it but for some reason the function move_and_slide won’t work, instead it says in the console “Line 15:Too many arguments for “move_and_slide()” call. Expected at most 0 but received 1.”

move and slide should stand alone
also, you should screenshot your code and the console so everyone can see and analyze the problem

1 Like

where should i put it then?

I don’t know what your game is but here is a code that makes your character move toward your mouse

func _physics_process(delta):
	mouse_pos = get_local_mouse_position()
	character_body_2d_3.position.x = (mouse_pos.x/8 + position.x)
	character_body_2d_3.position.y = (mouse_pos.y/8 + position.y)
	move_and_slide()
1 Like

You are using Godot 3 code in Godot 4. The function move_and_slide() changed, and now it works without arguments.

Dang I’m kinda used to Godot 3 more than 4

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.