Reputation: 11
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
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