Error: Too many arguments for "move_and_slide()" call

4.2.2

i was following this tutorial: https:youtu.be/1nqw4kt4Tkclist=PL8zFvrwKVF4h_sqmepUDveicsEkvGUhFb&t=929 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

In Godot 4, move_and_slide() doesn’t have any parameters. Just remove them from the function call.

2 Likes

thanks