First of all please note that the game is in 3d and Not 2d

The image below is seen from above. What I am trying to do is find a random point 2 - 3 meters around the player.

However I am not quite sure how to achieve it:

I have tried the following:

Vector3 randomPointOnCircle = Random.insideUnitSphere;
randomPointOnCircle *= radius;
return randomPointOnCircle;

However I am not sure how to set the player as the center?

enter image description here Star - Player

Square the general ground

Circle - A visual representation of where the points should be around the player

  • 2
    \$\begingroup\$ Your current code selects a point on a sphere, not on a circle. Is that intentional? \$\endgroup\$
    – DMGregory
    Jun 10, 2020 at 17:53

1 Answer 1


This is a trivial application of the unit circle:

Vector3 RandomPointOnXZCircle(Vector3 center, float radius) {
    float angle = Random.Range(0, 2f * Mathf.PI);
    return center + new Vector3(Mathf.Cos(angle), 0, Mathf.Sin(angle)) * radius;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .