IsPathPossible using a specific graph

I have 3 graphs in my scene, each that perform different functions. I would like to test the ability to get from point A to point B, but I want to test this against a single graph of my choosing.

Is there a way to use PathUtilities.IsPathPossible() and state which graph that it should attempt to calculate?

Hi

The IsPathPossible function uses cached information calculated elsewhere. It can only determine if two nodes are connected by a path or not. It doesn’t know if that path enters another graph along its route.
May I ask what use case you have for this?

Ah, that’s probably why I’ve been getting super inconsistent results when attempting to use it. There are times that it is returning false when immediately after I call StartPath and it calculates everything perfectly fine.

My use case is that I want to check if a path if possible before actually calculating it. If it’s not possible, then that means that the player put something in the way. So instead of throwing an error, I’d like to change the traversable tags, then attempt to calculate the path again.

How I ended up getting it working was to actually calculate the path, then if it threw an error, to change the traversable tags and try calculating it again. If it still doesn’t work, throw a debug error. I perform this in the OnPathComplete callback function.

    public void OnPathComplete(Path p)
    {
        if (p.error) {
            // If this is the first time, try again but allow going through obstacles instead of going around them.
            // If there's STILL an error, Then we have a legit issue.
            if(!obstacleBlocking) {
                obstacleBlocking = true;
                // All my obstacle tags that were previously not traversable are now traversable
                seekerScript.traversableTags += (1 << 12) | (1 << 13) | (1 << 14) | (1 << 15) | (1 << 16);
                Debug.Log(gameObject.name + " now climbing over obstacles");
                seekerScript.StartPath(transform.position,objective.transform.position,OnPathComplete);
            } else {
                Debug.LogWarning(gameObject.name + "path error: " + p.errorLog);
            }
        } else {
            path = p;
        }

It works fine, and I guess I can live with the core library throwing a debug warning, but I’d prefer to check the possibility of a path on the desired graph before actually having to calculate it.

Hi

If you used the IsPathPossible overload that took a tag mask you are probably better off with a path request anyway. The one which takes a tag mask doesn’t use precalculated information and instead has to check every single reachable node (which is pretty slow).

Btw

seekerScript.traversableTags += (1 << 12) | (1 << 13) | (1 << 14) | (1 << 15) | (1 << 16);

You probably don’t want to use an addition there. It doesn’t make any sense. Use either assignment or |= depending on what you want.

Cool, sounds like my current implementation is going to be the most ideal then.

Excellent tip - I didn’t know this operator existed! Thank you