PathUtilities.IsPathPossible returns a false positive

Hi, I’ve encounter a strage behaviour.

I’m using a navmesh and applying this function to determine if a path is possible between two points; o (origin) and d (destination):

        /// <summary>
        /// Checks if a path between the given positions is possible
        /// </summary>
        public bool IsPathPossible(Vector3 o, Vector3 d)
        {
            GraphNode node1 = Navmesh.GetNearest(o, NNConstraint.None).node;
            GraphNode node2 = Navmesh.GetNearest(d, NNConstraint.None).node;
            return PathUtilities.IsPathPossible(node1, node2);
        }

This always works at 60 FPS, however, when I cap the FPS lower, ex: 50, it returns true when it should return false.

The attached image represents a fail case, at 60 FPS the function determines that the path is not possible, however, when the game runs at lower framerates, it determines that the path is possible.

I’ve tried setting the maxNearestNodeDistancefield to zero, however it doesn’t fix the issue.

I’ll attach all the info I have:

My A* version is 4.2.18 and the Pathfinder component Inspector settings are the following ones:

O point position: X: -6.87 Y: -7.75 Z:0
D point position: X: -7.14 Y: -7.32 Z:0

I’ve uploaded the mesh (example_mesh_asset.asset) as an unity .asset file here.

Am I doing something wrong?

Thanks in advance,

Julen.

Hi

That’s very strange. The FPS should not matter at all.

You can check if the two regions have the same coloring using A* Inspector → Settings → Graph Coloring Mode (set it to ‘Areas’). If they have different colors then IsPathPossible should return false.

Btw. A max nearest node distance of 0 is probably not a good idea. That will make GetNearest return null for any point which is not exactly on the navmesh.

OK, so it seems like I misunderstood the function itself.

I was thinking about something like “the straight path is possible”.

I should’ve used something like:

    /// <summary>
    /// Checks if any obstacle exists between two given points
    /// </summary>
    public bool AnyObstacleBetweenPoints(Vector3 o, Vector3 d)
    {
        return Navmesh.Linecast(o, d, Navmesh.GetNearest(o, NNConstraint.None).node);
    }

I’m so sorry.

1 Like