Skip to content

Instantly share code, notes, and snippets.

@chabiribon
Created January 30, 2015 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chabiribon/2a61b7462c621844247f to your computer and use it in GitHub Desktop.
Save chabiribon/2a61b7462c621844247f to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class Generation : MonoBehaviour {
public GameObject Prefab1;
public GameObject Prefab2;
public GameObject Prefab3;
public GameObject Prefab4;
public GameObject Prefab5;
public float Timer = 1;
public float Xposition = 0;
public float Yposition = 6;
public float areaA = 0.0f;
public float areaB = 4.0f;
// Use this for initialization
void Start () {
StartCoroutine(Loop(Timer));
}
// Update is called once per frame
void Update () {
}
// Update is called once per frame
private IEnumerator Loop (float time) {
while (true){
yield return new WaitForSeconds(Timer);
float area = Random.Range(areaA,areaB);
int seisuu = Random.Range(0,5);
var array = new []{Prefab1,Prefab2,Prefab3,Prefab4,Prefab5};
Instantiate(array[seisuu],new Vector2(area,Yposition),Quaternion.identity);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment