Wont instantiate game object
I am creating a game that spawns prefabs from spawn points. It is supposed to spawn the prefab every 5 seconds. I have no idea why it is not spawning the prefab
 using UnityEngine;
 using System.Collections;
 
 public class OBCREATE : MonoBehaviour {
     Random rnd = new Random();
     int seconds; 
     int obj;
     public GameObject obst1;
     public GameObject obst2;
     public GameObject obst3;
     public GameObject obst4;
     public GameObject obst5;
     bool cando = true;
 
     // Use this for initialization
     void Start () {
 
     }
     IEnumerable Roll(){
         print("rolling");
         obj = Random.Range(1, 2);
         seconds = Random.Range(5, 10);
         yield return new WaitForSeconds(5);
         if(obj == 1)
             Instantiate(obst1, this.transform.position, Quaternion.identity);
         if(obj == 2)
             Instantiate(obst2, this.transform.position, Quaternion.identity);
     }
     IEnumerable Bacon(){
         cando = false;
         yield return new WaitForSeconds(5);
         cando = true;
     }
     // Update is called once per frame
     void Update () {
         if(cando){
             Bacon();
             Roll();
     }
 }
 }
 
 
              
               Comment
              
 
               
              Answer by tqkiettk10 · Oct 14, 2015 at 03:44 AM
Hey! Try to change IEnumerable to IEnumerator and when call function use StartCoroutine(Bacon());
Your answer