Unity C# - Spawning GameObjects randomly around a point
<p>I am not sure how to approach this problem or whether there are any built in Unity functions that can help with this problem so any advice is appreciated.</p>

<p>Here is an image that'll help describe what I want to do:
<a href="https://i.stack.imgur.com/sGDrc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sGDrc.jpg" alt="enter image description here"></a></p>

<p>I want to spawn Game Objects around a given point within the limits of a set radius. However their position in this radius should be randomly selected. This position should have the same Y axis as the origin point (which is on the ground). The next main problem is that each object should not clash and overlap another game object and should not enter their personal space (the orange circle).</p>

<p>My code so far isn't great:</p>

<pre><code>public class Spawner : MonoBehaviour {

    public int spawnRadius = 30; // not sure how large this is yet..
    public int agentRadius = 5; // agent's personal space
    public GameObject agent; // added in Unity GUI

    Vector3 originPoint;    

    void CreateGroup() {
        GameObject spawner = GetRandomSpawnPoint ();        
        originPoint = spawner.gameObject.transform.position;        

        for (int i = 0; i &lt; groupSize; i++) {           
            CreateAgent ();
        }
    }

    public void CreateAgent() {
        float directionFacing = Random.Range (0f, 360f);

        // need to pick a random position around originPoint but inside spawnRadius
        // must not be too close to another agent inside spawnRadius

        Instantiate (agent, originPoint, Quaternion.Euler (new Vector3 (0f, directionFacing, 0f)));
    }
}
</code></pre>

<p>Thank you for any advice you can offer!</p>