Self explanatory title, I’m interested in this because in order to have my Ai keep trying to reach a player logically I will need something to make it go to. If there are any alternative ways around doing this, please let me know.
Alternative title:
How to make a path always succeed
If you mean using the built in pathfinding system, I have not idea and its probably not possible. Most algorithms won’t give you an “can almost reach” path, since they are not designed to do this in a stable way. You can change your inputs to the algorithm to get what you want, but it depends on your use case. In what cases are you expecting pathfinding to give no possible path?
Never. I don’t quite care if a path is successful or not, I only want a path no matter what. If it’s a valid path that reaches the point, good. If not then it will just fail and try again
A humanoid is what i’m using. ----------- ( If you are going to suggest the use of moveto on error, im already doing that, and im not pleased with it, as it only goes in one direction and pretty much stays there if the path is truly unreachable )
The only thing I can think of is to find a place that is reachable that is as close as possible to the unreachable point. If you know that your graphs are disconnected (the path will for sure be unreachable, known in advance), you can find the closest node on a reachable graph and pathfind to that instead.
Thats a huge question, there are different strategies for finding “nearest” of something that trade off massively between performance and complexity. You could pre-calculate some list of “bridges” between points that may become unreachable, and thus separate two graphs. This could handle things like doors, and that might work really well if you are controlling an NPC enemy, since it makes sense for them to go to a nearby door if it can’t find a way into somewhere otherwise.
At some point you will simply have to manually place some info required by the pathfinder, the algorithms we have just aren’t smart enough to figure everything out manually. In games that have doors/windows that NPCs can move through, these are called “portals”, I think valve calls them brushes. The famous one I remember are the crates of de_dust in the original counter strike. They have special markers near them telling the AI it can get on to of there only if it jumps down from above or jumps up from right next to them.