Best last node from a failed path computation?

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?

2 Likes

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

Adding on, I’ve tried making my own algorithm in the past, but it seems too much work and headaches for something so simple

What is the thing you are using the path for. I.e. are you “steering” something like a humanoid or vehicle?

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.

i’ve also thought about that, but how would i even do this efficiently?

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.

1 Like

That seems very needy, especially for big maps. And how would I even be sure i covered every “unreachable” spot?

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.

1 Like