Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections.Generic;
- public class CloudGen : MonoBehaviour {
- public Camera cam;
- public GameObject Player;
- public GameObject[] CloudsSprites = new GameObject[3];
- GameObject Currentcloud;
- List<GameObject> CloudsOnStage = new List<GameObject>();
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- void Update () {
- if(Player.transform.position.y > 10)
- Invoke("Generate", 3);
- }
- void Generate()
- {
- if(Currentcloud == null || CloudsOnStage.Capacity <= 10)
- CloudsOnStage.Add((UnityEngine.GameObject)Instantiate(CloudsSprites[Random.Range(0, 2)], new Vector3(Random.Range(cam.rect.xMax, cam.rect.xMin), transform.position.y + 10), this.transform.rotation));
- else Instantiate(CloudsSprites[Random.Range(0, 2)], new Vector3(Random.Range(cam.rect.xMax, cam.rect.xMin), transform.position.y + 50 + Currentcloud.transform.position.y), this.transform.rotation);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment