Vector2:Cross is mislabeled as returning a Vector2

The page on Vector2 lists the return type of Vector2:Cross as a Vector2, when it’s actually a number. That caused a bug in my code and should be corrected.


Doesn’t cross product give back a vector? How is it a number?

It gives back a number. The reasoning (I assume) is that there’s only one useful component for vectors created by crossing 2D vectors so it just returns that.

1 Like

Yeah that’s a logical explanation, perhaps it’s the magnitude of that vector. Anyways, I hope they check it out.

It’s actually because the result cannot be given back as a vector at all, because the cross vector would point out of the 2d plane, so it cannot be represented with a vector2 since it has no Z component. If you were to put it in the X/Y and keep the other coordinate empty, that wouldn’t be the cross vector anymore since it misses the property of being perpendicular to both input vectors.

This is exactly why cross products with vector2 always confuses me, I don’t even see a point for it

The sign of the result (+/-) tells you if the first vector is clockwise/anticlockwise from the other (i.e. which rotating direction brings you to the other vector faster).

The absolute value you can use to determine things such as the size of the parallelogram formed by the two vectors, and if you half that you get the size of the triangle formed by the two vectors.


You can also take the arcsin of the cross product to get the theta angle. There are other ways to compute these things via dot product to get the angle between the vectors first, but cross seems to be fewer operations to get these values for 2D.


Thank you for this little explanation!

1 Like