Enemy Spawner
This commit is contained in:
parent
8794d913bf
commit
17c95b8f01
27
Assets/Scripts/EnemySpawner.cs
Normal file
27
Assets/Scripts/EnemySpawner.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class EnemySpawner : MonoBehaviour {
|
||||||
|
|
||||||
|
public float delay;
|
||||||
|
public GameObject[] enemyPrefabs;
|
||||||
|
public Transform[] spawnPoints;
|
||||||
|
|
||||||
|
void Start() {
|
||||||
|
StartCoroutine(SpawnRoutine());
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator SpawnRoutine() {
|
||||||
|
while(true) {
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(delay);
|
||||||
|
|
||||||
|
int enemyIndex = Random.Range(0, enemyPrefabs.Length);
|
||||||
|
int positionIndex = Random.Range(0, spawnPoints.Length);
|
||||||
|
|
||||||
|
GameObject newEnemy = Instantiate(enemyPrefabs[enemyIndex], spawnPoints[positionIndex].position, Quaternion.identity, transform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
11
Assets/Scripts/EnemySpawner.cs.meta
Normal file
11
Assets/Scripts/EnemySpawner.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 980fcc6b06b84694080efd936a8fbcf0
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user