Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class EM : MonoBehaviour
  4. {
  5. public PlayerHealth playerHealth; // Reference to the player's heatlh.
  6. //public GameObject enemy; // The enemy prefab to be spawned.
  7. public float spawnTime = 3f; // How long between each spawn.
  8. public Transform[] spawnPoints; // An array of the spawn points this enemy can spawn from.
  9. public GameObject[] enemy;
  10.  
  11. void Start ()
  12. {
  13. InvokeRepeating ("Spawn", spawnTime, spawnTime);
  14. }
  15.  
  16.  
  17. void Spawn ()
  18. {
  19.  
  20. int spawnPointIndex = Random.Range (0, spawnPoints.Length);
  21. int enemyIndex = Random.Range (0, enemy.Length);
  22.  
  23. Instantiate (enemy[enemyIndex], spawnPoints[spawnPointIndex].position, spawnPoints[spawnPointIndex].rotation);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement