Description
The Length
property of the Vector2Int
struct represents the magnitude or length of the vector. It calculates the distance from the origin (0,0) to the point defined by the vector's x and y components. This property returns a float
value, which is the Euclidean distance calculated using the Pythagorean theorem.
Usage
To access the Length
property, you need to have an instance of Vector2Int
. This property is read-only and provides the magnitude of the vector, which can be useful for determining the size or distance of the vector from the origin.
Example
Vector2Int vector = new Vector2Int(3, 4);
float length = vector.Length;
// length will be 5.0, as the vector (3, 4) forms a 3-4-5 right triangle.