Checked all over but to no avail. In my scene there is a single navmesh that is divided into two via a NavMeshObstacle set to Carve. This obstacle is dynamically moved via script to allow and disallow translation between the two sides of the map by AI.
The problem though - there are roam points on each side of the map the AI navigate to when not attacking. But I can’t figure out how to make AI avoid roam points that are unreachable because of the carving obstacle.
Below is an example of what my scene looks like. The bar in the middle acts like a gate that splits the navmesh down the middle of two bridges. When it is split, Ai should stay on their sides but when the ‘gate’ is raised, passage should be allowed on both ends.
I have tried checking the path completion status of the NavMeshAgent like this, where “point” is the position of every roam point being checked.
public bool CanNavigateToPoint(Vector3 point)
NavMeshPath cache_navpath = new NavMeshPath();
if (agent.CalculatePath(point, cache_navpath))
return (cache_navpath.status == NavMeshPathStatus.PathComplete)
But that has not worked, so when a list is built for all “reachable” roam points, even the ones on the opposite side of the gate are added to the list and the AI attempts to reach points that it cannot, stopping just outside the gate.
Can anyone help me out here?