I want from green,red,blue,yellow to be spawn at spawn_1,…spawn_4 ones. What does this mean is that for those four spawn possition only ones of those colors can be Instantiate and no more of the same.
using UnityEngine;
using System.Collections;
public class Spawner : MonoBehaviour
{
public float respawn_speed;
public GameObject red;
public GameObject green;
public GameObject blue;
public GameObject yellow;
public GameObject spawn_1;
public GameObject spawn_2;
public GameObject spawn_3;
public GameObject spawn_4;
void Start()
{
StartCoroutine(Example());
}
IEnumerator Example()
{
yield return new WaitForSeconds(respawn_speed);
GenerateClone();
Repeat();
}
void Repeat()
{
StartCoroutine(Example());
}
public void GenerateClone()
{
Instantiate (red, spawn_1.transform.position, Quaternion.identity);
Instantiate (green, spawn_2.transform.position, Quaternion.identity);
Instantiate (blue, spawn_3.transform.position, Quaternion.identity);
Instantiate (yellow, spawn_4.transform.position, Quaternion.identity);
}
}