Taking this a little further, we can create another script that can be used to spawn multiple enemies at once.
Go to the
MyGame/Scripts
folder, navigate to Create | New C# Script, and call itSpawnEnemiesOnTrigger
. Once you've finished, double-click on the created file to open MonoDevelop.Once the file is opened, put in the following code if you're using RAIN:
using UnityEngine; using System.Collections; using System.Collections.Generic; // List public class SpawnEnemiesOnTrigger : MonoBehaviour { // Enemy to spawn public GameObject enemy; // Where to be spawned at public List<Transform> spawnPoints; // Has this happened already? private bool hasTriggered = false; void OnTriggerEnter(Collider other) { //If the player touches the trigger, and if it hasn't // been triggered before if(other.tag == "Player" && hasTriggered == false) { foreach(var spawnPoint in spawnPoints) { // Spawn...