title: How would I instantiate an object every 5 to 7 seconds?
body: <p>I'm working on a jumping game for Android in Unity and I'm slightly puzzled as to how to go about instantiating a prefab every 5 or so seconds. I have tried using a <code>while</code> loop, but i end up making an infinite loop by mistake! The camera in the game continuously moves upward while the player has to keep the ball bouncing while not hitting anything and avoiding obstacles. I have the code to create an obstacle prefab, I just don't know how to make it loop and create a prefab after the camera has moved for 5 seconds. Any help is greatly appreciated!</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class ObjectCreate : MonoBehaviour {
  
      public GameObject MovingBar;
      GameObject MovingBarClone;
  
      void Start () {
          CreateClone();
      }
  
      void CreateClone() {
          MovingBarClone = Instantiate(MovingBar, transform.position, Quaternion.identity) as GameObject;
          Destroy(MovingBarClone, 15);
      }
  }
  </code></pre>