The Distance
method calculates the Euclidean distance between the current Vector2Int
instance and another specified Vector2Int
instance. This method is useful for determining how far apart two points are in a 2D integer grid.
The Distance
method calculates the Euclidean distance between the current Vector2Int
instance and another specified Vector2Int
instance. This method is useful for determining how far apart two points are in a 2D integer grid.
To use the Distance
method, you need to have two Vector2Int
instances. Call the method on one instance and pass the other instance as a parameter. The method will return a float
representing the distance between the two vectors.
Vector2Int pointA = new Vector2Int(3, 4); Vector2Int pointB = new Vector2Int(7, 1); float distance = pointA.Distance(pointB); // distance will be 5.0, which is the Euclidean distance between the points (3,4) and (7,1)