Hi guys,
I want to randomized the location of my clone objects at different time but I want to retain the same amount of clone objects. What should i do? I want my clones to continuously changing their location. Here’s my coding.
void Start ()
{
StartCoroutine (waitSpawner());
}
void FixedUpdate ()
{
spawnWait = Random.Range (spawnLeastWait,spawnMostWait);
}
IEnumerator waitSpawner ()
{
yield return new WaitForSeconds (startWait);
while (!stop)
{
randFood = Random.Range (0, foods.Length);
countClones = Random.Range (0, clones.Length);
Vector3 spawnPosition = new Vector3 (Random.Range (-spawnValues.x, spawnValues.x), 1, Random.Range (-spawnValues.z, spawnValues.z));
clones [countClones] = Instantiate (foods [randFood], spawnPosition, gameObject.transform.rotation);
i += 1;
yield return new WaitForSeconds (spawnWait);
}
}
Thanks!