Right now I am making a timed "escape" themed game where the player must find pieces of their ship that have scattered upon crashing in order to get off the planet. The player must avoid the enemies that will end up chasing them throughout the level.
My current problem is figuring out how to get multiple enemies to follow once it is triggered.
Right now only the one follows but the other 5 in the area don't move. I was thinking about putting them into an array but I'm unsure if that will work as I need to access the navmeshagent component
Here is my code:
#pragma strict
//script by Kyle Crombie & Paul Christopher
//will add negative action if collision is detected with player
var target : Transform; //the enemy's target
var isSeen: boolean = false;
var agent: NavMeshAgent;
function OnTriggerStay() {
isSeen = true;
target = GameObject.FindWithTag("Player").transform; //target the player
}
function Update () {
if(isSeen){
agent.SetDestination(target.position);
}
}