cannot use official tutorial using arguents in move_and-slide call

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RohanLockley

Hello all!

i’m currently following the first part of the tutorial in the official documentation ,to propperly learn to use godot.
I do get an error however, when using the move_and_slide call, as it expects 0 arguments instead of 5:

i figured it could have been a change in godot 4.0, but i can’t really figure out the docs it sais here that move_and_slide is a bool?
if i remove the arguments it tells me there’s an invalid getindex ‘y’ so it is defenitely my fault somewhere it doesnt work

i did manage to move in worldspace using the automaticly assigned script where move_and_slide is calles without arguments :

	if direction:
	velocity.x = direction.x * SPEED
	velocity.z = direction.z * SPEED
	velocity.x = move_toward(velocity.x, 0, SPEED)
	velocity.z = move_toward(velocity.z, 0, SPEED)

but that uses world coordinates. my script extends from CharacterBody3d.

The tutorial documentation you linked above is for Godot 3.2, but you mention that you’re using Godot 4. Those are likely to have lots of differences. Though, maybe you didn’t intend to link the 3.2 document?

jgodfrey | 2022-12-28 19:16

:bust_in_silhouette: Reply From: RohanLockley

I did fix it - adding it here so others who have this issue can find the solution a bit quicker maybe:

my new code:
hvel = hvel.lerp(target, accel * delta) vel.x = hvel.x vel.z = hvel.z set_velocity(vel) move_and_slide() print("processing movement")

you dont seem to need to do all the calculations, just use set_velocity, then tell godot to move and slide. i do have to adjust my gravity, but it seems to work otherwise.