Enemy Spawner

This commit is contained in:
Yann Dupont 01 2022-04-02 00:40:32 -04:00
parent 8794d913bf
commit 17c95b8f01
2 changed files with 38 additions and 0 deletions

View 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);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 980fcc6b06b84694080efd936a8fbcf0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: