- Home /
Question by
Alvarosh40 · Nov 05, 2013 at 09:02 AM ·
ainavmeshagent
WayPoints navMeshAgents help
how i can know if my AI was reach to the destination?
function Update()
{
GetComponent(NavMeshAgent).destination = target.position;
if(GetComponent(NavMeshAgent).destination == target.position){
Debug.Log("WayPoint1");
}
}
is dosen't work...
Comment
Answer by Sasmaster · Nov 16, 2013 at 10:33 AM
if(GetComponent(NavMeshAgent).remainingDistance == 0.0F){//or use some epsilon here
Debug.Log("Arrived to target");
}
I know this is super old post, but remember that the remainingDistance property will be Infinity if the Nav$$anonymous$$eshAgent doesn't compute a direct line of site with the destination.
So in general it's better to use Vector3.distance(startpos, endpos) than remainingDistance for the situation you were describing.