October 2015
Beginner
326 pages
5h 43m
English
Taking this a little further, we can create another script that can be used to spawn multiple enemies at once.
MyGame/Scripts folder, navigate to Create | New C# Script, and call it SpawnEnemiesOnTrigger. Once you've finished, double-click on the created file to open MonoDevelop.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 ...Read now
Unlock full access