I wrote a piece of code but I would like it to spawn one out of two prefabs every 4 seconds. NO matter what I try and where I look I just can't do it. Help would be greatly appreciated. Thanks. (the second variable is redball) `using UnityEngine;
using System.Collections;
public class BallSpawner : MonoBehaviour {
public GameObject purpleball; public float delayTime = 4f;
IEnumerator Start()
{
var obj = Instantiate(purpleball, transform.position, transform.rotation) as GameObject;
yield return new WaitForSeconds(delayTime);
StartCoroutine(Start());
}
}`
↧