Support Forum

Trying to find a path to an unreachable position returns a path

I am using the grid graph to calculate paths and was surprised to see the seeker return a path close to the target (but no errors) when the target is an unreachable position. What I was expecting was to not get a path or an error, if the target is unreachable. Is this behavior intended or am I making a mistake somewhere?

To elaborate a bit more: I am setting up a path and letting the seeker do its work on it.

var vector3Path = ABPath.Construct(agent.transform.position, targetPosition.value.position, null);
seeker.StartPath(vector3Path, OnPathComplete);

If I check path.errors, it returns false and and path.CompleteState returns complete.
My path looks like this:


The last point on the returned path is as close as possible to the target and not on the node position but on the border.
I tried setting calculatePartial to false before seeking, but that doesn’t seem to have any effect.
The only way I found to deal with this is to use IsPathPossible beforehand and not letting the seeker look for a path if none is possible, as I don’t want to move my objects at all if they cannot reach their intended goal.
Is this the right way to go about this or am I missing anything?

Hey,
You can use the IsPathPossible function to test if the path is possible at all. You don’t need to apply it to the agent

1 Like

Hi ToastyStoemp, thank you for your answer.
As I wrote above, using IsPathPossible is what I am doing right now. I was just wondering if I understood the system correctly or if I was making any stupid mistakes. :confused:

nope, using the IsPathPossible has almost no performance hit, so it’s safe to use it :slight_smile:

1 Like

The typical unreachable condition would be distance to the target point if i’m not wrong, as even if an area is unwalkable but a character can stand next to it and for example grab something it’s still reachable.
So checking the distance of the desired point to the last path point should give the wanted result.
The pathing system has to have a certain search radius as the navmesh is just an approximation of the actual walkable ground.
You can also query for the nearest node to the target point and check that against the desired max distance. That way you can check it for walkability first before submitting a path request, if that’s what you need.

1 Like