Guest User

Untitled

a guest
Jun 24th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3.  
  4. public class CloudGen : MonoBehaviour {
  5.  
  6.     public Camera cam;
  7.     public GameObject Player;
  8.     public GameObject[] CloudsSprites = new GameObject[3];
  9.     GameObject Currentcloud;
  10.     List<GameObject> CloudsOnStage = new List<GameObject>();
  11.  
  12.     // Use this for initialization
  13.     void Start () {
  14.    
  15.     }
  16.    
  17.     // Update is called once per frame
  18.     void Update () {
  19.         if(Player.transform.position.y > 10)
  20.             Invoke("Generate", 3);
  21.     }
  22.  
  23.     void Generate()
  24.     {
  25.         if(Currentcloud == null || CloudsOnStage.Capacity <= 10)
  26.         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));
  27.         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);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment