using UnityEngine;
using System.Collections;

public class Spawner : MonoBehaviour
{
		public GameObject thing;
		public float interval = 1;
		public float chance = 1;
	
		float releaseTime;
		float height;

		void Start ()
		{
				releaseTime = Time.time + interval;
				height = Camera.main.ViewportToWorldPoint (Vector2.one).y;
		}
	
		void Update ()
		{
				if (releaseTime < Time.time && Random.Range (1, 100) <= chance) {
						GameObject t = (GameObject)Instantiate (thing);
						t.transform.position = new Vector2 (10, Random.Range (-height, height));
						releaseTime = Time.time + interval;					
				}	
		}
}
