Jepsi
April 6, 2024, 5:18am
1
Godot Version
4
Question
(I just started using godot )
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.”
Jepsi:
“move_and_slide()”
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
Jepsi
April 6, 2024, 5:36am
4
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.
Jepsi
April 6, 2024, 8:06am
7
Dang I’m kinda used to Godot 3 more than 4
system
Closed
May 6, 2024, 8:06am
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.