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?
thiskeyword 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 usegameObjectto refer the instance of GameObject you are working on. And you can usetransformdirectly to refer the Transform assigned to the GameObject you are working on. \$\endgroup\$