I was working on a little project in the Unity game engine. I was doing something with transform.position, until I ran into a problem. I needed to use a negative number for the z coordinates, but whenever I use a negative number,
I the following error: error CS0119: Expression denotes a type', where a variable', value' or method group' was expected
So I lead to the conclusion that there was a problem with a negative number. I couldn't find anything related to this, so I decided to ask a question. Here is part of my code:
transform.position = Vector3(32.23805f, 0.4999998f, -17.32514f);
This isn't a problem with using negative values. You are missing the "new" keyword.
Try this:
transform.position = new Vector3(32.23805f, 0.4999998f, -17.32514f);
when not using the new keyword, the compiler would assume that you are trying to declare a type of a variable instead of assigning a value to the trasform.position variable. that is why you are getting the error
Expression denotes a type', where a variable', value' or method group' was expected
just add the new keyword and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With