Guest User

Untitled

a guest
Apr 17th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class spawning : MonoBehaviour
  6. {
  7. // other vars
  8. int randNumb;
  9. public GameObject enemyGO;
  10.  
  11. // spawners var
  12. public GameObject spawner1;
  13. public GameObject spawner2;
  14. public GameObject spawner3;
  15. public GameObject spawner4;
  16. public GameObject spawner5;
  17.  
  18. void Start()
  19. {
  20.  
  21. }
  22.  
  23. // Update is called once per frame
  24. void Update()
  25. {
  26. if(Input.GetKeyDown(KeyCode.U)){
  27. randGen();
  28. spawn();
  29. }
  30. }
  31.  
  32. void randGen(){
  33. randNumb = Random.Range(1, 6);
  34. print(randNumb);
  35. }
  36.  
  37. void spawn(){
  38. if(randNumb == 1){
  39. Instantiate(enemyGO, spawner1.transform.position, spawner1.transform.rotation);
  40. }
  41.  
  42. if(randNumb == 2){
  43. Instantiate(enemyGO, spawner2.transform.position, spawner2.transform.rotation);
  44. }
  45.  
  46. if(randNumb == 3){
  47. Instantiate(enemyGO, spawner3.transform.position, spawner3.transform.rotation);
  48. }
  49.  
  50. if(randNumb == 4){
  51. Instantiate(enemyGO, spawner4.transform.position, spawner4.transform.rotation);
  52. }
  53.  
  54. if(randNumb == 5){
  55. Instantiate(enemyGO, spawner5.transform.position, spawner5.transform.rotation);
  56. }
  57. }
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment