SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class BoxController : MonoBehaviour
  6. {
  7.     public GameObject box;
  8.     public int boxCount;
  9.     void Start()
  10.     {
  11.  
  12.     }
  13.        
  14.     void Update()
  15.     {
  16.         boxCount = GameObject.FindGameObjectsWithTag("box").Length;
  17.         if (!IsInvoking("FallBox"))
  18.         {
  19.             if (boxCount < 5)
  20.             {
  21.                 Invoke("FallBox", 5);
  22.             }
  23.         }
  24.     }
  25.     void FallBox()
  26.     {
  27.         boxCount += 1;
  28.         Vector2 position = new Vector2(Random.Range(-14f, 15f), Random.Range(10f, 20f));
  29.         Instantiate(box, position, Quaternion.identity);
  30.     }
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top