In the 3d fps tutorial godot documentation, there is a line of code near the bottom that's outdated. I am new to coding with godot, I have a little bit of experience with java script but that's it. The line of code looks like this.
VVV
vel = move_and_slide(vel, Vector3(0, 1, 0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
I know to fix the deg2rad part, it should be deg_to_rad, but once I do that it gives me this error.
Too many arguments for "move_and_slide()" call. Expected at most 0 but received 5.
I don't know what to try because like I said I am new to coding with godot, I understand a little bit of GDScript, but not enough to fix this problem on my own.
As the error message says, move_and_slide()
doesn’t take any parameters anymore since Godot 4. Instead you’re supposed to assign the CharacterBody3D
’s velocity property, then call move_and_slide()
.
I recommend you check out some of the example projects from the Asset Library, where you may find code like this:
var input_dir := Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
var direction := input_dir.rotated(-global_rotation.y)
velocity.x = lerp(velocity.x, direction.x * speed, accel * delta)
velocity.z = lerp(velocity.z, direction.y * speed, accel * delta)
velocity.y -= gravity * delta
move_and_slide()