I have the following line of code from a project I'm working on:

this.transform.position += (keyMapping.Value * this.movementSpeed).Scale(this.transform.forward);

At a first glance, this line of code looks like it should work, yet, I get the following error when I try to run it:

error CS0019: Operator `+=' cannot be applied to operands of type `UnityEngine.Vector3' and `void'.

I'm stumped as to what might be causing this. How do I fix this?

  • \$\begingroup\$ Please note that, this keyword will refer to current instance of the "class" you are working on, which is a script. In your case, the code will work but you should use gameObject to refer the instance of GameObject you are working on. And you can use transform directly to refer the Transform assigned to the GameObject you are working on. \$\endgroup\$ Commented Jan 2, 2016 at 22:17

1 Answer 1


Vector3.Scale with one parameter input does not return a value so you will need to apply Scale as a separate step.

var movement = (keyMapping.Value * this.movementSpeed);
transform.position += movement;



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .