i keep geting the same error massage (invalid operands 'Vector3' and 'Nil' in operator '*')every time i run the scene

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

i keep geting the same error massage (invalid operands ‘Vector3’ and ‘Nil’ in operator ‘*’)every time i run the scene

direction = direction.normalized()
h_velocity = h_velocity.linear_interpolate(direction * speed, h_acceleration * delta)
movement.z = h_velocity.z + gravity_vec.z
movement.x = h_velocity.x + gravity_vec.x
movement.y = gravity_vec.y

the erorr is in movement.z

From what I can tell, one of those variables doesn’t have a value (or rather, the value is null). The problem may be in the assignment to the hvelocity variable, in the parameters to the linearinterpolate() function.

Ertain | 2021-08-12 09:14

:bust_in_silhouette: Reply From: timothybrentwood

Based on the code snippet you posted, your speed variable in the script is not initialized before you execute the hvelocity line. Adding speed = 50 or whatever to your script should resolve your issue.

If speed is already set to a value in the script, you will need to post more code because those aren’t the lines where the error is happening.