Random Coordinates Outside a Circle

Hi all,

I understand that there's a Random.insideUnitCircle variable to get a random 2D coordinate inside a theoretical circle.

But what if I wanted to get a random 2D coordinate outside of that theoretical circle? Any ideas on how to go about that?

Thanks in advance,


Broadly, this is what I would do:

  1. Randomise a position within the min/max bounds
  2. Check distance from the centrepoint to the randomised position
  3. If it's less than a desired radius, recalculate the random position

Be aware that sqrMagnitude is much faster than Vector2.magnitude. To use this, you will then obviously need to square the radius value. For example:

if ( (randomPos.position - centrePoint.position).sqrMagnitude <= radius*radius )
{ // retry }