Hello!
I have a simple little problem, i am sure most of you would laugh at me. I guess i simply don’t know some syntax here.
I am working on a 2D game, so i am using a lot of Vector2-s. When i store multiple Vector2-s in an array, like Vector2[ ], they don’t lose their datatype. But for some implementation i am using the ‘Javascript Array’ instead, the one you create with new Array(), because they have dynamic length.
So, when i am iterating through my javascript Array called ‘points’, it turns out that it contains objects, not Vector2-s. They print out just fine, but i cannot access their properties as ‘.x’ and ‘.y’. So i do this to every element before processing:
var vect:Vector2 = points[i];
It runs just fine, but i get this warning:
BCW0028: WARNING: Implicit downcast from 'Object' to 'UnityEngine.Vector2'.
I would happily downcast it in a proper way, like accessing the coordinates separately from ‘points*’, but i seem to find no way to do it. Both*
* *print(points[i].x); print(points[i][0]);* *
give me errors.
* *print(points[i]);* *
just wors fine, outputting the element like that:
* *(20.0, 1.0) UnityEngine.MonoBehaviour:print(Object)* *
Please help, how can i separately address the values in an Object like that? Also, why do Vector2-s become Objects when put into an Array in the first place?