The Distance
method calculates the distance between the current Vector3
instance and a target Vector3
instance. This method is useful for determining how far apart two points in 3D space are.
The Distance
method calculates the distance between the current Vector3
instance and a target Vector3
instance. This method is useful for determining how far apart two points in 3D space are.
To use the Distance
method, you need to have two Vector3
instances. Call the method on one instance and pass the other instance as a reference parameter. The method will return a float
representing the distance between the two vectors.
Vector3 pointA = new Vector3(1.0f, 2.0f, 3.0f); Vector3 pointB = new Vector3(4.0f, 5.0f, 6.0f); float distance = pointA.Distance(ref pointB); // distance now holds the value of the distance between pointA and pointB.