enzo
enzo

Reputation: 11

error code CS1061 operator '*' con't be applied to operands of type 'Vector 3' and 'Vector3'. How do I sort this out

Hi I'm trying to create movement in unity for a character based on velocity with my script but the error CS0019 Operator '' cannot be applied to operands of type 'Vector3' and 'Vector3'* keeps coming up. I've tried the solution of a similar question, Error CS0019: Operator * cannot be applied to operands of types 'Vector3' and 'Vector3 but it doesn't work.

here's my code(velocity is a vector3):

rb.MovePosition(rb.position * velocity * Time.fixedDeltaTime);

Upvotes: 1

Views: 238

Answers (1)

Philipp Lenssen
Philipp Lenssen

Reputation: 9218

To move the rigidbody by velocity, instead of your

rb.MovePosition(rb.position * velocity * Time.fixedDeltaTime);

try use

rb.MovePosition(rb.position + velocity * Time.fixedDeltaTime);

Note you can also move a rigidbody via AddForce(). Good luck!

Upvotes: 1

Related Questions