Advertisement
Guest User

Untitled

a guest
Jan 1st, 2021
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Spawner : MonoBehaviour
  6. {
  7. public GameObject[] gearVariants;
  8.  
  9. private float timeBtwSpawn;
  10. public float startTimeBtwSpawn;
  11. public float decreaseTime;
  12. public float minTime = 0.65f;
  13.  
  14. private void Update()
  15. {
  16. if (timeBtwSpawn <= 0)
  17. {
  18. int rand = Random.Range(0, gearVariants.Length);
  19. Instantiate(gearVariants[rand], transform.position, Quaternion.identity);
  20. timeBtwSpawn = startTimeBtwSpawn;
  21. if (startTimeBtwSpawn > minTime)
  22. {
  23. startTimeBtwSpawn -= decreaseTime;
  24. }
  25. }
  26. else
  27. {
  28. timeBtwSpawn -= Time.deltaTime;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement