ABPath stuck in Created state

I’ve got a game with a maze, and an NPC that can jump walls if it finds a shorter path to its destination on the other side of a wall. My goal is to construct paths for each eligible neighbor cell and compare their lengths. If one of the paths from a neighbor cell is shorter than the current path, my NPC will jump the wall and start on that shorter path.

Problem is, the PipelineState for the ABPaths I construct never leave the Created state. IsDone() is never true, and the coroutine is stuck in the second while loop. Am I missing something? I can’t find documentation for starting the process of constructing the individual paths, and it looks like the ABPath.Construct() function should do that already. Is there an issue with calling that function in a coroutine for some reason? I’m at a loss.


    IEnumerator AttemptJump()
        jumpCandidateCell = null;

        // Check each neighbor cell and construct a path to the destination for eligible paths
        MazeCell currentCell = wandering.CurrentCell;
        if (NeighborCanBeJumpedTo(currentCell.RightNeighbor, 0))
            pathList.Add(ABPath.Construct(currentCell.RightNeighbor.Intersection.transform.position, aiPath.destination));
        if (NeighborCanBeJumpedTo(currentCell.TopNeighbor, 1))
            pathList.Add(ABPath.Construct(currentCell.TopNeighbor.Intersection.transform.position, aiPath.destination));
        if (NeighborCanBeJumpedTo(currentCell.LeftNeighbor, 2))
            pathList.Add(ABPath.Construct(currentCell.LeftNeighbor.Intersection.transform.position, aiPath.destination));
        if (NeighborCanBeJumpedTo(currentCell.BottomNeighbor, 3))
            pathList.Add(ABPath.Construct(currentCell.BottomNeighbor.Intersection.transform.position, aiPath.destination));

        // Stop attempt if no eligible paths
        if (pathList.Count == 0)
            yield break;

        // Wait for all paths to be calculated
        float shortestLength = aiPath.remainingDistance;
        while (pathList.Count > 0)
            while (!pathList[0].IsDone())
                Debug.LogFormat("Waiting: {0}", pathList[0].PipelineState.ToString());
                yield return null;

            // Check if constructed path is shorter than shortest path
            float pathLength = pathList[0].GetTotalLength();
            if (pathLength < shortestLength)
                shortestLength = pathLength;
                jumpCandidateCell = Maze.GetCellAtPos(pathList[0].originalStartPoint);
                Debug.LogFormat("{0} is shorter!", jumpCandidateCell.name);
                Debug.LogFormat("{0} is not faster than the shortest path", Maze.GetCellAtPos((Vector3)pathList[0].path[0].position).name);

            // Remove path from the list

        if (jumpCandidateCell != null)

Thank you!


The .Construct is like a constructor, it only creates the instance but it doesn’t calculate the path.
Take a look at this page for more info: https://arongranberg.com/astar/docs/callingpathfinding.html

1 Like

Thank you for the reply!

The documentation suggests that ABPath.Construct() should create the instance and start calculating the path on a separate thread/coroutine, since one of the method overloads asks for a delagate to call when calculations complete. I’m sure I’m just not understanding something, but I can seem to find any calls to start calculating an ABPath instance in its documentation manually, either.


It takes a callback, yes, but that is saved for later.
You add it to the calculation queue using seeker.StartPath, or in some use cases AstarPath.StartPath (this is the one you should use since you are calculating multiple paths in parallel). See the documentation page I linked to above.

1 Like

Okay, I looked into the docs more, and it’s starting to make more sense. I’m gonna run some tests tomorrow and see if I can get things working! Thank you for your help!

1 Like

That did the trick! I apologize for being so dense. Thank you again!

1 Like