using UnityEngine;
using System.Collections;
public class spawner : MonoBehaviour {
public GameObject obj1;
public GameObject obj2;
public GameObject obj3;
public GameObject obj4;
public GameObject obj5;
public bool spawned;
public float chooser;
public float sec;
void Start () {
StartCoroutine (spawning ());
chooser = Random.Range (1, 5);
sec = Random.Range (1, 5);
}
// Update is called once per frame
void Update () {
spawning ();
}
IEnumerator spawning()
{
if (chooser == 1) {
Instantiate (obj1, transform.position, Quaternion.identity);
}
if (chooser == 2) {
Instantiate (obj2, transform.position, Quaternion.identity);
}
if (chooser == 3) {
Instantiate (obj3, transform.position, Quaternion.identity);
}
if (chooser == 4) {
Instantiate (obj4, transform.position, Quaternion.identity);
}
if (chooser == 5) {
Instantiate (obj5, transform.position, Quaternion.identity);
}
yield return new WaitForSeconds (2);
chooser = Random.Range (1, 5);
sec = Random.Range (1, 5);
}
}
This dosent work , it dosent spawn anything , can you pls help me ?
So put chooser before yield return new WaitForSeconds (2); ?
– CrazyLule