How do I detect, and prevent, a character pathfinding to an inaccesible place

Hi, think I’m being stupid here…

So, I have an AI, who moves around based on an enemy’s location. Trouble is, the enemy is often in an inaccesible location, so basically I want the AI to check if it’s possible to pathfind to a location, if they can, they go, if not, they don’t… the logic I can do, I just need to find out how to run the check.

Right now, no such check happens in my game, so the seeker path returns a direct A to B to desired location, which is obviously impossible, and my AI ends up running at a wall. Detecting ‘can I get there’ before trying to get there would solve this. I kinda wonder if that’s just a functionality in the seeker I’m unaware of.

Oh, and to make things more fun, environment is built at runtime, so I can’t preflag rooms, this has to happen entirely based on the pathfinder data generated by a runtime scan.

Thanks, and apologies for noobishness

Have you tried using PathUtilities.IsPathPossible(…)? It’ll return true/false depending on the result.

Here’s a simple example that grabs the closest node to each position:
`Node node1 = AstarPath.active.GetNearest(myLocation).node;
Node node2 = AstarPath.active.GetNearest(enemyLocation).node;

bool isPathPossible = PathUtilities.IsPathPossible(node1, node2);
Debug.Log("Is path valid? : " + isPathPossible);
`

awesome, thanks FinalMirage :slight_smile: