29 lines
808 B
C#
29 lines
808 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class SimpleEnemySpawner : MonoBehaviour
|
||
|
|
{
|
||
|
|
[SerializeField] private EnemyController enemyToSpawn;
|
||
|
|
[SerializeField] private Transform spawnPoint;
|
||
|
|
[SerializeField] private float timeBetweenSpawns;
|
||
|
|
[SerializeField] private int amountToSpawn;
|
||
|
|
private float spawnCounter;
|
||
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
spawnCounter = timeBetweenSpawns;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Update is called once per frame
|
||
|
|
void Update()
|
||
|
|
{
|
||
|
|
spawnCounter -= Time.deltaTime;
|
||
|
|
if(spawnCounter <= 0f)
|
||
|
|
{
|
||
|
|
spawnCounter = timeBetweenSpawns;
|
||
|
|
Instantiate(enemyToSpawn, spawnPoint.position, spawnPoint.rotation);
|
||
|
|
amountToSpawn--;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|