📜  c#获取vector2距离 - C#代码示例

📅  最后修改于: 2022-03-11 14:49:24.150000             🧑  作者: Mango

代码示例1
//For 2D Unity C#
float GetDistance(Vector2 posA, Vector2 posB) {
    float dx = posA.x - posB.x;
    float dy = posA.y - posB.y;
    float distance = Mathf.Sqrt(dx * dx + dy * dy);
    return distance;
}