check if object is reachable on NavMesh
I know it has been asked before but every "answer" had a link to a page 404 not found anymore. Situation is I have an AI character following me but sometimes I leave the NavMesh area. Then the character continues to run in place like an idiot until I get back on NavMesh. I want to set a condition so if I can't e followed they do to an idle and wait. That all I can do ( idle and wait) but don't now how to write the condition. best "answer I found is this:
Use NavMeshAgent.SetDestination and then wait until the path has been calculated to determine if it is valid or not (you can use a coroutine and wait until !NavMeshAgent.PathPending and then check NavMeshAgent.pathStatus once completed)"
But don't get how to code it
Answer by shadowpuppet · Nov 28, 2018 at 04:49 PM
wow....that was easy. I just have the code for DeBug for now but it does the trick
if(agent.pathPending == true)
Debug.Log ("WAITING");
if(agent.pathPending == false)
Debug.Log ("FOLLOWING");