Description
The Length
property of the Vector2Int
struct provides the magnitude of the vector. It calculates the distance from the origin (0,0) to the point represented by the vector. This is useful for determining the size or extent of the vector in a 2D space.
Usage
To access the Length
property, simply call it on an instance of Vector2Int
. This property is read-only and returns a float
representing the magnitude of the vector.
Example
Vector2Int vector = new Vector2Int(3, 4);
float length = vector.Length;
// length will be 5.0, as it is the hypotenuse of a 3-4-5 right triangle.