- Home /
Question by
Razputin · Jul 08, 2021 at 02:17 AM ·
ainavmeshnavmeshagentpathfindingpath
Find the closest point of an Invalid or Partial path
If I have a navmeshpath that is calculated as either invalid of partial, can I retrieve the point at which the path becomes invalid/partial and tell my agent to go there instead?
Essentially...
NavMeshPath path = new NavMeshPath();
agent.CalculatePath(target.position, path);
switch (path.status)
{
case NavMeshPathStatus.PathComplete:
agent.SetDestination(ai.target.position);
break;
case NavMeshPathStatus.PathPartial:
agent.SetDestination(//closest point of the partial path);
break;
case NavMeshPathStatus.PathInvalid:
agent.SetDestination(//closest point of the invalid path);
break;
}
Comment
Not sure but try with corners to estimate the path in each case: https://docs.unity3d.com/540/Documentation/ScriptReference/NavMeshPath-corners.html