- Home /
NavMeshAgent stops when player is in inaccesible area
My NavMeshAgents are following my player around the scene which works fine, the issue is when I enter a zone they cannot access, they stop moving until i leave to an area they can reach me from. The weird issue is, even though they stop and cannot reach me, their pathStatus shows as pathCompleted rather than PathInvalid. Is there a reason for this?
Preferably, I would like them to go to the last position of the player before entering the inaccessible area. Is there a way I can achieve this?
if (agent.enabled == true)
{
agent.SetDestination(currentTarget.transform.position);
//I could say
//If PathInvalid
//Go to last known point
}
As in my comment, if their path status showed as Invalid, I could use that as a starting point, but it never shows invalid.
Answer by MakeCodeNow · Sep 21, 2015 at 02:54 AM
It's possible but you'll need to keep track of the last valid player position yourself and then when the player enters an invalid area set a new destination to that last valid position.
Not sure why Unity is returning that the path is completed rather than invalid. Maybe a bug in their code?
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
Enemy follow Camera 0 Answers
how to make navmeshagent walk smarter 0 Answers
Nav Mesh problem~ I need help! 0 Answers
navmesh.sampleposition works strangely, what is going on here? 0 Answers