- Home /
Question by
sonatkaran · Oct 19, 2014 at 03:30 PM ·
navmeshnavmeshagent
NavMesh Agent doesn't work stable
Hi , I'm using NavMeshAgent on my enemies. There are more than 40 enemies in my game and all of them use same scripts(they all are duplicated from same prefab.) Some of them working well but some of them are delayed. They triggered but not moving for 10-15 seconds. after this delay they work normally.
void Update ()
{
if (isDead == false) {
if (eatAnimFinished) {
ZombieDetector (transform.position, maxDistance);
if (Detector) {
WalkAwayFromZombie ();
} else {
//A function which is using NavMesh
WalkTowardToPlayer (player);
}
}
}
}
void WalkTowardToPlayer (GameObject player)
{
agent = GetComponent<NavMeshAgent> ();
agent.SetDestination (player.transform.position);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613165431im_/https://answers.unity.com/themes/thub/images/avi.jpg)