Is there a better way to search a blocker

Using the latest version of the plugin. Using a 2D Grid Graph and the built-in AIPath script for AI movement.

Currently working on the bones of a Tower defense project. So far I have a decent grasp of the Plugin but clearly, there’s a lot of information to digest. Currently in the project the player can place blocking barricades to get the hordes to path down a desired route. So the grid graph is blocked off from both the “Defenses” Layer for placed barricades, and the “Wall” layer for the static terrain of the level.

However, to prevent the player from simply walling off the enemy objective, if no path is available they’re instructed to find the closest barricade and destroy it. Simple enough logically through a basic FSM. I can get nearby blockers well enough, but depending on the shape of the terrain, the “closest” blocker could technically be through a solid wall. So I need some sort of check to ensure the path is possible before selecting the closest blocker. However, I’m running into issues with the IsPathPossible method in PathUtilities, since it’s trying to check to a blocker itself. So it will inconsistently run perfectly fine or tank performance since all nearby blockers end up failing.

I’m really uncertain about the best approach for this. But so far these are my conclusions on the issue.

I have to avoid physics checks due to the sheer number of AIs walking through the scene.

Additionally, I could add a small system to each barricade adding points along its rectangular perimeter, then check pathing to each of those points, but that seems needlessly complicated and taxing to the system.

My current search method that gets me the nearest barricade is a Grid Spatial Partition of all the barricades that each enemy searches through, which is fast but doesn’t resolve the issue of barricades on the other side of walls being considered closer.

Is there so sort of way to search for blockers of a specific layer type along a path? Or is there a more proper way of pathfinding to a blocker?

Any help at all would be greatly appreciated!

Hi

There’s an API just for this purpose!
You may be interested in GraphUpdateUtilities - A* Pathfinding Project

See the bottom of this page for more details: Graph Updates - A* Pathfinding Project