Published
- 1 min read
c# get vector2 distance
The solution for this is noted below
c# get vector2 distance
Solution
//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;
}
Try other methods by searching on the site. That is if this doesn’t work