A* Pathfinding Project

Swimming path failed at certain height (Solved)


#1

As the title states, when my AI are following a target that is moving across water, the path will fail at certain points and after a while, teleport somewhere far away (usually underground somewhere).

The recast graph follows the ground on the bottom of the lake. The AI uses the RVO controller as well as the AI Path components. It can either be swimming on the surface of the water or somewhere between the surface and the ground and is completely determined by the target. For testing, I am having the AI follow the player. Swimming works great until the AI reaches a certain depth in the water.

Once this depth is reached, the path to the target will always fail with: Path Failed : Computation Time 0.00 ms Searched Nodes 0. After a few seconds, if you don’t push the AI back to shallow waters (or push them underwater), it will randomly teleport away.

To test that this does happen at a certain depth and it’s not just a random point on the graph, I swam across the bottom of the lake with the AI following me. Once I was at a certain distance from the shore, I swam straight up and sure enough, the AI lost it’s path on the way up.

Is the path failing because it is too far above the recast graph? If it is, is there a way to omit checking the height above the graph? It’s not really needed as the AI can both swim or levitate depending on situations.


#2

Does anybody know why this is could be happening? It seems to be connected to the targets height above the grid and not specifically the NPCs position.

Edit:
Nevermind. It seems to be a consequence of the “Max Nearest Node Distance” setting. Increasing that fixed the problem.


#3

Hi

Increasing max nearest node distance will work, however the agents aren’t really designed to be that far away from the graph.
I would recommend that you also enable ‘Nearest Node Queries in XZ space’ to make sure that the agents find the nodes straight below them instead of the nearest node (which may be significantly off to the side in some cases if the agent is far from the graph surface).


#4

I have enabled that as well. Thanks for all the help, this is a great asset that has saved me a lot of time so far.