- Home /
How to check if vector in array was not changed?
Hello. I have stuck with one problem. I want to check, whether a vector2 in my vector2 array has never been changed since I created my array. With integer array this was quite simple:
if (intarray[0] == default(int))
... but with vector2 array this does not work:
if (vector2array[0] == default(Vector2))
So how can I check if vector2 has been changed from it's default value? Thank you.
Comment
Best Answer
Answer by $$anonymous$$ · May 11, 2015 at 03:33 PM
Just store an "OldValue" of that Vector like this:
private void Update()
{
if (OldVect != vector2array[0])
// Vector has Changed
OldVect = vector2array[0];
}
Thank you! Although this was not the straightforward way to solve my problem, it gave me a strong and huge clue how to do it. Thank you again!
I don't know the context, but in some cases it might be better to "check" when you are changing the value in the array, that would be more reactive approach.