Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class EM : MonoBehaviour
- {
- public PlayerHealth playerHealth; // Reference to the player's heatlh.
- //public GameObject enemy; // The enemy prefab to be spawned.
- public float spawnTime = 3f; // How long between each spawn.
- public Transform[] spawnPoints; // An array of the spawn points this enemy can spawn from.
- public GameObject[] enemy;
- void Start ()
- {
- InvokeRepeating ("Spawn", spawnTime, spawnTime);
- }
- void Spawn ()
- {
- int spawnPointIndex = Random.Range (0, spawnPoints.Length);
- int enemyIndex = Random.Range (0, enemy.Length);
- Instantiate (enemy[enemyIndex], spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement