how to generate random number of spawning objects outside a given point in a circle

Is there a way that you could make a random number of the same object spawn in random order around a given point. like if i had a sphere in the middle is there a way to have a random amount of cubes spawn in a circle around it every second. Im making a game where you try and protect the center by slashing objects that move toward the object in the center, but i cant figure out how to make a spawning system that will allow me to have a random amount of objects spawn in a circle around a the middle non moving object.


Here is a function that generates a random position around a central point. I’ve included a minDist and a maxDist so there the possibility of a bit of spread. If you want to spawn exactly on a circle, set them both to the same value or recode the line that uses them to use a fixed value. ‘center’ is the point you want to spawn around. You will need to call this function once for each Instantiate() to get the position.

function RandomAround (center : Vector3, minDist : float, maxDist : float) : Vector3 {
	var v3 = Quaternion.AngleAxis(Random.Range(0.0, 360.0), Vector3.up) * Vector3.forward;
	v3 = v3 * Random.Range(minDist, maxDist);
	return center + v3;