42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class spawner : MonoBehaviour
|
||
|
{
|
||
|
//get enemy and king prefab
|
||
|
public GameObject enemy;
|
||
|
public GameObject king;
|
||
|
public int numkings = 3;
|
||
|
public int numenemies = 30;
|
||
|
|
||
|
// Start is called before the first frame update
|
||
|
void Start()
|
||
|
{
|
||
|
//spawn enemies
|
||
|
for (int i = 0; i < numenemies; i++)
|
||
|
{
|
||
|
//spawn enemy
|
||
|
GameObject enemyclone = Instantiate(enemy, new Vector3(Random.Range(5, 100), Random.Range(-70, -60), Random.Range(-100, 0)), Quaternion.identity);
|
||
|
//set enemy name
|
||
|
enemyclone.name = "enemy" + i;
|
||
|
enemyclone.tag = "enemy";
|
||
|
}
|
||
|
//spawn kings
|
||
|
for (int i = 0; i < numkings; i++)
|
||
|
{
|
||
|
//spawn king
|
||
|
GameObject kingclone = Instantiate(king, new Vector3(Random.Range(5, 100), Random.Range(-70, -60), Random.Range(-100, 0)), Quaternion.identity);
|
||
|
//set king name
|
||
|
kingclone.name = "king" + i;
|
||
|
kingclone.tag = "king";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
}
|