Support Forum

How do I stop the AI from pathfinding to the target on a different floor?

So I have noticed that if the target is inaccessible on another floor, it will move to the X/Z position of the target, but on the wrong floor.

A building with 2 floors.
The target is on floor 2, but is unreachable.
So the Character moves to the X/Z position of the target but on floor 1.

I am using the Layered Grid Graph.

How can I stop them please? I would rather they not move at all. Does it call something when the path cannot be found that I can intercept perhaps?

Thanks :slight_smile:


You can reduce the A* Inspector -> Settings -> Max Nearest Node Distance to make the path fail if the closest point on the navmesh is too far away from the destination.

Hi thanks for the reply. The problem with that method is I want them to be able to reach far destinations if the path is clear. I want if they cant reach the destination for them to never move at all.


You can check if there is a path to the destination using IsPathPossible.

I’ve added that now, thanks for that. I still get the original issue though. It seems they consider another floor for the target as a valid path. I’m assigning the target destination to the AIDestinationSetter script.

So I need a way that allows people to move to targets on other floors, but not move to floors that the target isnt actually on.
Is it possible to get the position of the node it is targetting and compare that to the target on the Y coordinate? That way I can check if it is targetting another floor and block it from doing so.

Thanks :slight_smile: