title: Random points with radius
body: <p>I have a dilemma on an algorithm. I'm trying to generate 6 random positions that have a distance between them. My algorithm works, only to check the distance between the current point and the previous point. What I need is for the algorithm to verify the distance between all points and if the distance is less than the indicated value, it will generate a new position.</p>
  
  <pre><code>private void Generate()
  {
      for (int i = 0; i &lt;= 5; i++)
      {
          Vector3 pos = PointsGenerator();
          Instantiate(point, pos, Quaternion.identity); // just to highlight the points on the screen
      }
  }
  
  private List&lt;Vector3&gt; Dist = new List&lt;Vector3&gt;();
  private bool isOver = false;
  private Vector3 PointsGenerator()
  {
      Vector3 currentPosition = Vector3.zero;
      Vector3 oldPosition = Vector3.zero;
      float distance = 0f;
      do
      {
          currentPosition = new Vector3(UnityEngine.Random.Range(minX, maxX), UnityEngine.Random.Range(minY, maxY), 0f);
          for (int i = 0; i &lt; Dist.Count; i++)
          {
              distance = Vector2.Distance(currentPosition, Dist[i]);
              if (distance &lt;= 4f)
              {
                  isOver = true;
                  break;
              }
              else
                  isOver = false;
          }
  
      } while (isOver == true);
      Dist.Add(currentPosition);
      return currentPosition;
  }
  </code></pre>
  
  <p>Thanks to all who will give advice.</p>