文章来源:https://www.uudwc.com/A/Nx5Mv/
public float GetDistance(Vector3 startPoint, Vector3 endPoint)
{
float distance = (startPoint - endPoint).magnitude;
return distance;
}文章来源地址https://www.uudwc.com/A/Nx5Mv/
方法2
public double GetDistance(Vector3 startPoint, Vector3 endPoint)
{
double x = System.Math.Abs(endPoint.x - startPoint.x);
double y = System.Math.Abs(endPoint.y - startPoint.y);
return Math.Sqrt(x * x + y * y);
}