• Godot Help
  • Error: Too many arguments for "move_and_slide()" call.

i was following this tutorial:
and i got this error. "Too many arguments for "move_and_slide()" call. Expected at most 0 but received 3."

code:
extends CharacterBody3D

#///basic variables///

var gravity = -30
var max_speed = 8
var mouse_sensitivity = 0.002

#///gun variables///

#///functions///

func _ready():
Input.set_mouse_mode(Input. MOUSE_MODE_CAPTURED)

func get_input():
var input_dir = Vector3()
if Input.is_action_pressed("move_foward"):
input_dir += -global_transform.basis.z
if Input.is_action_pressed("move_back"):
input_dir -= -global_transform.basis.z
if Input.is_action_pressed("strafe_left"):
input_dir += -global_transform.basis.x
if Input.is_action_pressed("strafe_right"):
input_dir -= -global_transform.basis.x
#input_dir = input_dir.normalized() #add to cancel strafe running
return input_dir

func _unhandled_input(event):
pass

func _physics_process(delta):
#gravity
velocity += gravity * delta
var desired_velocity = get_input() * max_speed
velocity.x = desired_velocity.x
velocity.z = desired_velocity.z
velocity = move_and_slide(velocity, Vector3.UP, true)

func change_gun(gun):
pass

func _process(delta):
pass

    I'm still new to Godot so I apologize if my advice isn't perfect

    JetteBoyTV "move_and_slide()" call. Expected at most 0 but received 3."

    basically what this Error means is that the built in function move_and _slide() doesn't accept any arguments, as in you don't put anything in the parenthesis at the end, just leave it as is

    JetteBoyTV velocity = move_and_slide(velocity, Vector3.UP, true)

    here you put 3 arguments in the parenthesis, you gotta leave it like this "move_and_slide()"

    also I've never worked with 3D before in Godot (only 2D) but I think that you might be calling move_and_slide() incorrectly, when i call move_and_slide() in my 2D games I simply just put move_and_slide() at the end of my movement function or whatever, like this

    	if input != 0:
    		if input > 0:
    			velocity.x += speed * delta
    			velocity.x = clamp(speed, 100.0, speed)
    			$Sprite2D.scale.x = 1
    		if input < 0:
    			velocity.x -= speed * delta
    			velocity.x = clamp(-speed, 100.0, -speed)
    			$Sprite2D.scale.x = -1
    	if input == 0:
    		velocity.x = 0
    	gravity_force()
    	move_and_slide() #I simply called it here !

    I'm not sure if you can do something like

    Velocity = move_and_slide()

    or maybe I'm completely wrong and you can just do that in 3D !

      xyz oh yeah that's super important in Godot since some things changed between Godot 3 and Godot 4

      5 days later

      and many things changing from 4.2 to 4.3..