Set calculatePartial to true

Hi Aron,

Playing with the Door1 example, I observed when the door is closed, I get the bellow error:
“Searched all reachable nodes, but could not find target. This can happen if you have nodes with a different tag blocking the way to the goal. You can enable path.calculatePartial to handle that case workaround (though this comes with a performance cost)”

To solve this I tried to set the calculatePartial field to true, in the AIDestinationSetter script at the Update function:
void Update ()
{
Path path = seeker.GetCurrentPath();
ABPath aBPath = (ABPath)path;
if (path != null)
aBPath.calculatePartial = true;
if (target != null && ai != null) ai.destination = target.position;
}

I’m not sure if this is the right way to set true the calculatePartial?
But it seems that in this way I get an other error:
Exception: Some path is not cleaning up the flag1 field. This is a bug.
Pathfinding.ABPath.CompleteWith (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Pathfinders/ABPath.cs:568)

@aron_granberg can you please help me with this question?

Hi

You need to set calculatePartial before the path calculation starts.
You can do this either by subclassing the AIPath script and changing how it creates its path. Or you can disable the agents internal path calculation logic (canSearch=false) and supply your own paths using ai.SetPath(myCustomPathWithOtherSettings).

Right now you are modifying the field in the middle of the path calculation. And since the path calculation is multithreaded, the other thread gets confused.

I also am having this error and don’t understand your answer to fix it.

I’m setting calculatePartial = true when the Path is created, but it results in the same flag1 error:

        public override void SearchPath()
        {
            if (float.IsPositiveInfinity(destination.x)) return;
            if (onSearchPath != null) onSearchPath();

            Vector3 start, end;
            CalculatePathRequestEndpoints(out start, out end);

            // Request a path to be calculated from our current position to the destination
            ABPath p = ABPath.Construct(start, end, null);
            p.calculatePartial = true; // Custom change
            SetPath(p, false);
        }

Even if i go to ABPath and hardcode calculatePartial = true i still get the error.

Continuing discussion in Closest Point Ignored when Nodelink2 tag is not traversable