Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class spawning : MonoBehaviour
- {
- // other vars
- int randNumb;
- public GameObject enemyGO;
- // spawners var
- public GameObject spawner1;
- public GameObject spawner2;
- public GameObject spawner3;
- public GameObject spawner4;
- public GameObject spawner5;
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- if(Input.GetKeyDown(KeyCode.U)){
- randGen();
- spawn();
- }
- }
- void randGen(){
- randNumb = Random.Range(1, 6);
- print(randNumb);
- }
- void spawn(){
- if(randNumb == 1){
- Instantiate(enemyGO, spawner1.transform.position, spawner1.transform.rotation);
- }
- if(randNumb == 2){
- Instantiate(enemyGO, spawner2.transform.position, spawner2.transform.rotation);
- }
- if(randNumb == 3){
- Instantiate(enemyGO, spawner3.transform.position, spawner3.transform.rotation);
- }
- if(randNumb == 4){
- Instantiate(enemyGO, spawner4.transform.position, spawner4.transform.rotation);
- }
- if(randNumb == 5){
- Instantiate(enemyGO, spawner5.transform.position, spawner5.transform.rotation);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment