Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# get vector2 distance

//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;
}
 
PREVIOUS NEXT
Tagged: #distance
ADD COMMENT
Topic
Name
7+7 =