The Vector2.Distance
method calculates the Euclidean distance between two 2D vectors. This method is static and can be used to determine how far apart two points are in a 2D space.
The Vector2.Distance
method calculates the Euclidean distance between two 2D vectors. This method is static and can be used to determine how far apart two points are in a 2D space.
To use the Vector2.Distance
method, pass two Vector2
references as parameters. The method will return a float
representing the distance between the two vectors.
Vector2 pointA = new Vector2(1.0f, 2.0f); Vector2 pointB = new Vector2(4.0f, 6.0f); float distance = Vector2.Distance(ref pointA, ref pointB); // distance will be approximately 5.0