Instantiate Object on random Radius

Hello!

I have made an empty GameObject which is my randomSpawner and added this script on it:

using UnityEngine;
using System.Collections;

public class RandomSpawner : MonoBehaviour 
{
	
	bool isSpawning = false;
	public float minTime = 5.0f;
	public float maxTime = 15.0f;
	public GameObject[] enemies;  // Array of enemy prefabs.

	float randomY = Random.Range(-5f,0.0f, 5f);    
	float rightScreenBound = 10; 

	IEnumerator SpawnObject(int index, float seconds)
	{
		Debug.Log ("Waiting for " + seconds + " seconds");
		
		yield return new WaitForSeconds(seconds);
	//	Instantiate(enemies[index], transform.position, transform.rotation);

//		Vector3 position = new Vector3(Random.Range(-10.0F, 10.0F), 0, Random.Range(-10.0F, 10.0F));
		Instantiate(enemies[index], new Vector3(rightScreenBound, randomY, 0), Quaternion.identity);


		//We've spawned, so now we could start another spawn     
		isSpawning = false;
	}
	
	void Update () 
	{
		//We only want to spawn one at a time, so make sure we're not already making that call
		if(! isSpawning)
		{
			isSpawning = true; //Yep, we're going to spawn
			int enemyIndex = Random.Range(0, enemies.Length);
			StartCoroutine(SpawnObject(enemyIndex, Random.Range(minTime, maxTime)));
		}
	}
}

Actually it is only spawning an Object “behind the Scenes” and it’s always on the same Position.

I want to spawn objects in a circle around my spawnObject (randomSpawner),

Do you know what is Happening wrong?

Thank you

You need to randomise Y every time you spawn an object. i.e. randomY = Random.Range(-5f,0.0f, 5f); needs to be inside SpawnObject() (in fact, I’m surprised your current code even compiles). But this still won’t instantiate objects in a circle - it’ll distribute them randomly on a line of x=10. For randomly within a circle, try Random.insideUnityCircle.

Please check