Answers for "get random point within radius"

C#
0

get random point within radius

/// <summary>
/// Returns a random point within a certain radius
/// of a given point
/// </summary>
/// <param name="centerPoint"></param>
/// <param name="radius"></param>
/// <returns></returns>
public Vector3 GetRandomPointInsideCircle(Vector3 centerPoint, float radius)
{
    Vector3 point = Random.insideUnitSphere * radius;
    point.z = 0;
    point += centerPoint;
    return point;
}
Posted by: Guest on May-03-2020

Code answers related to "get random point within radius"

C# Answers by Framework

Browse Popular Code Answers by Language