Hi I have this code now. When another GameObject spawns i would want to delete/hide the previous one and i would like to know which GameObject did it spawned. I am still a noob but I am trying :D
Thanks!
{
public GameObject[] arrows;
public float interval = 5;
// Use this for initialization
void Start()
{
StartCoroutine(SpawnArrow());
}
public IEnumerator SpawnArrow()
{
WaitForSeconds delay = new WaitForSeconds(interval);
while (true)
{
GameObject prefab = arrows[UnityEngine.Random.Range(0, arrows.Length)];
GameObject clone = Instantiate(prefab, new Vector3(0.02F, 2.18F, -1), Quaternion.identity);
yield return delay;
}
}`
↧