Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement