new to an engine,got a problem

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

so i was following the gdquest tutorial on 3d movement and got a problem

velocity=move_and_slide_with_snap(velocity,snap_vector,Vector3.UP,false)
if velocity.length() > 0.2:
	var look_angle=Vector2(velocity.z,velocity.x)
	nose.rotation.y=look_angle.angle()

but it just gives me this error

Invalid call. Nonexistent function 'length' in base 'Vector3'.

could someone please tell me why?
and how the hell length function works in gdscript
for someone who only used js before the concept of using length for something other then string or array is really strange and confusing

You are right, a vector3 probably can’t have a length.

ceayo | 2022-08-04 11:19

:bust_in_silhouette: Reply From: ceayo

Vector3 docs says

float length ( )
Returns the length (magnitude) of this vector.

Maybe you should try

velocity=move_and_slide_with_snap(velocity,snap_vector,Vector3.UP,false)
if velocity.length() > 0.2:
    var look_angle=Vector2(velocity.z,velocity.x)
    nose.rotation.y=look_angle.angle()