I need the Nav Mesh Stop , I need the Animation to Play Javascript
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.<Animation>().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.
Your answer
Follow this Question
Related Questions
Enemy is not taking damage! 0 Answers
Enemy not following player, navmeshagent AI 0 Answers
Idle , Move and Attack animations 0 Answers
How to enemy animation attack player 0 Answers
Enemy Animation Play 0 Answers