Created
October 28, 2017 22:06
-
-
Save JonathanYin/6e59c764f2b33790792cc574b89f1c77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class EnemyManager : MonoBehaviour | |
{ | |
public PlayerHealth playerHealth; | |
public GameObject enemy; | |
public float spawnTime = 3f; | |
public Transform[] spawnPoints; | |
void Start () | |
{ | |
InvokeRepeating ("Spawn", spawnTime, spawnTime); | |
} | |
void Spawn () | |
{ | |
if(playerHealth.currentHealth <= 0f) | |
{ | |
return; | |
} | |
int spawnPointIndex = Random.Range (0, spawnPoints.Length); | |
Instantiate (enemy, spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment