Today im struggling with vectors, and im having problems with this. I have to invert the Y vector value but everytime i compile , Compiler complains about:
Syntax error ',' expected
vector = new Vector3((float) ((-256 + ((iD & 7) * 0x40)) + 0x20), (float) ((-512 + ((iD / 8) * 0x40)) + 0x20), -200f) {
Y = -vector.Y; //error shows here at the semicolon
};
You're using object initializer syntax.
The compiler is correct.
You would place a comma there, instead of the semicolon, if you were to initialize more than one property. The comma is also legal even after the last property being initialized, but a semicolon is not legal.
So either of the following two is OK:
Having said that, this will only satisfy the compiler. What are you really trying to do?
Please note that at the point where you read
vector.Y, thevectorvariable has not yet been given a new value, so you're reading the old value.Basically, the code is doing this:
Why aren't you simply assigning that through the constructor instead?