Hi forum, im pretty new to Pathfinding in Unity and stumbled upon this issue:
I have an agent that tryies to track down the player. Now my problem is, what happens when the player is surrounded by obstacles that the enemy cant pass.
How can i tell the agent to ignore the player and instead start to attack the obstacles?
Thanks in advane
Take a look at SetPath. I believe you can use this to check if the path is reachable. You could probably use a if statement to figure out what to hit next.
Actually NavMeshAgent.CalculatePath is what you want.
It will return a path with a status of NavMeshPathStatus.PathPartial
agent = GetComponent<NavMeshAgent>();
NavMeshPath path = new NavMeshPath();
agent.CalculatePath(target.position, path);
if (path.status == NavMeshPathStatus.PathPartial) {
// target point is not reachable
}
2 Likes