- Home /
Problem is not reproducible or outdated
Unity 4.2 - adding to a Vector2 is broken???
Hi Guys - I've been driven mad today after updating to 4.2 (I have to stay on 4.2 because the other team members have updated about a week ago)
Basically the code worked fine when I was in 4.1 but for some gods awful reason wont now.
All I'm trying to do is update the x/y value of a Vector2
originally it was like this:
miniMapVector.x += miniMapSize + miniMapSize / 2;
which worked fine, but now the value of miniMapVector ( a Vector2 ) refuses to update, even debugging the value on either side of the expression returns no difference, eg
Debug.Log( "just before adding " + miniMapVector );
miniMapVector.x += miniMapSize + miniMapSize / 2;
Debug.Log( "just after adding " + miniMapVector );
returns the same value each time, even creating a new Vector2 and assigning it to miniMapVector doesnt work
Debug.Log( "just before adding " + miniMapVector );
miniMapVector = new Vector2( miniMapVector.x - miniMapSize + miniMapSize / 2, miniMapVector.y );
Debug.Log( "just after adding " + miniMapVector );
Am I going mad? Am I doing something illegal? Please help my sanity is at stake!
Answer by DaveA · Aug 13, 2013 at 06:10 PM
I don't know how you've declared your vars, but for kicks and good measure, try putting an 'f' after your literals, like this:
miniMapSize / 2f;
And see if that makes a difference. Been bit myself by this, where it assumes int but you intend float.
agghhh, ok, that didnt work - but I figured it out. I think I've been working too long today...
The value for $$anonymous$$i$$anonymous$$apSize got reset in the update. bangs Head against wall thanks for your input anyhoo!
Follow this Question
Related Questions
Vector2 is always (0,0) - HELP 1 Answer
Layers from PSD as sprites, support in 4.3? 1 Answer
Deriving and angle from two points 1 Answer
Need help with Vector3s and Vector2s 2 Answers
Replacement for LookAt in 2D 1 Answer