Advertisement
tomicz

Untitled

Jun 8th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SpawnScript : MonoBehaviour {
  5.  
  6. public GameObject[] obj; // Here you insert spawning objects in game editor
  7. public float spawnMin = 0f; // Min seconds to spawn objects
  8. public float spawnMax = 0f; // Max seconds to spawn objects
  9.  
  10.  
  11. // Use this for initialization
  12. void Start () {
  13.  
  14.  
  15. Spawn (); // Calls spawn function
  16.  
  17.  
  18. }
  19.  
  20.  
  21.  
  22. void Spawn()
  23. {
  24.  
  25. Instantiate(obj[0], transform.position, Quaternion.identity); // This spawns objects
  26. Invoke ("Spawn", Random.Range (spawnMin, spawnMax)); // This repeats the process
  27.  
  28. }
  29.  
  30.  
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement