Initial Commit
This commit is contained in:
28
Assets/Scripts/SimpleEnemySpawner.cs
Normal file
28
Assets/Scripts/SimpleEnemySpawner.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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--;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user