I am almost done setting up my enemy ai . The only thing I need is the nav mesh to stop and play one more animation . I can set the nav mesh to stop in the inspector . When I trying to code it getting an error. I need the attack animation to play ' when it get's near the player. Here is what I got so far : var target : Transform; //the enemy's target
var isSeen: boolean = false;
function Awake()
{
GetComponent.().Play("idle");
}
function OnTriggerEnter()
{
GetComponent.().Play("move");
GetComponent.().Stop("idle");
}
function OnTriggerExit() {
isSeen = true;
target = GameObject.FindWithTag("Respawn").transform; //target the player
}
function OnTriggerStay()
{
GetComponent.().Play("move");
}
function Update ()
{
if(isSeen)
{
for (var agent in GameObject.FindGameObjectsWithTag("Player"))
{
agent.GetComponent(NavMeshAgent).SetDestination(target.position);
}
}
}
Help would really be appreciated.
↧