Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BoxController : MonoBehaviour
- {
- public GameObject box;
- public int boxCount;
- void Start()
- {
- }
- void Update()
- {
- boxCount = GameObject.FindGameObjectsWithTag("box").Length;
- if (!IsInvoking("FallBox"))
- {
- if (boxCount < 5)
- {
- Invoke("FallBox", 5);
- }
- }
- }
- void FallBox()
- {
- boxCount += 1;
- Vector2 position = new Vector2(Random.Range(-14f, 15f), Random.Range(10f, 20f));
- Instantiate(box, position, Quaternion.identity);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement