I finally got the idea random spawn going, but now need help in wanting the spawning prefabs located within a rectangle area. Here are ideas of want I mean from these web links. how to create a spawn point within shape area for unity - Google Search
Also here is the random spawn script that I made if needed to apply where for the rectangle script to go to.
public GameObject objectToSpawn;
public GameObject parent;
public int numberToSpawn;
public int limit = 15;
public float rate;
float spawnTimer;
// Start is called before the first frame update
void Start()
{
spawnTimer = rate;
}
void Update()
{
if (parent.transform.childCount < limit)
{
spawnTimer -= Time.deltaTime;
if (spawnTimer <= 0f)
{
for (int i = 0; i < numberToSpawn; i++)
{
Instantiate(objectToSpawn, new Vector3(this.transform.position.x + GetModifier(), this.transform.position.y + GetModifier())
, Quaternion.identity, parent.transform);
}
spawnTimer = rate;
}
}
}
float GetModifier()
{
float modifier = Random.Range(-10.5f, 10.5f);
if (Random.Range(0, 2) > 0)
return -modifier;
else
return modifier;
}
}