[ProVersion] path found but vectorPath is too short

Hi

I am searching for a path in a PointGraph and the path was found.
But vectorPath gives me only a part of the positions of the final path.
It ends somewhere in the middle.

if (p.error)
{
Debug.LogError(“path not found”);
}
else
{
Debug.Log(“path found”);

for (int i = 0; i < p.vectorPath.Count; i++)
{
    Debug.Log(p.vectorPath[i]);
}

}

Greetings
Thomas

Hi

How does the path look in the scene view? The Seeker component should draw the calculated path in green.

Hi

I can see a green line.
Our LineRenderer is showing the same.

Greetings
Thomas

Do you think you could post a Screenshot of this? Ideally also of your graph in the scene view.

That looks like something you have generated in a custom way. Would you mind sharing more details about that?

Also what are your seeker settings (the start end modifier more specifically)

Hi

We have our own data of nodes. Each node has a position and more or less neighbor-nodes. From this data we built the data for the pointGraph. (addNode and addConnection)

The thing is: In most cases we get correct resultPaths. Only some combinations of startNode and endNode do not work.

We set both, StartPointSnapping and EndPointSnapping, to “Original”. We tried also the other settings.

In the PathFinder-Component we set “Max Nearest Node Distance” to 1000000.
With lower values, the startNode could be found but not the endNode.

//
Node nodeStart = listAStarQueueItem[0].nodeStart;
Node nodeEnd = listAStarQueueItem[0].nodeEnd;

            Vector3 pointNodeStart = AstarPath.active.GetNearest(new Vector3(nodeStart.x, nodeStart.y, nodeStart.z), Pathfinding.NNConstraint.None).position;
            Vector3 pointNodeEnd = AstarPath.active.GetNearest(new Vector3(nodeEnd.x, nodeEnd.y, nodeEnd.z), Pathfinding.NNConstraint.None).position;

           Pathfinding.NNInfo nnInfo_Start = AstarPath.active.GetNearest(new Vector3(nodeStart.x, nodeStart.y, nodeStart.z), Pathfinding.NNConstraint.None);
           Pathfinding.NNInfo nnInfo_End = AstarPath.active.GetNearest(new Vector3(nodeEnd.x, nodeEnd.y, nodeEnd.z), Pathfinding.NNConstraint.None);

seeker.StartPath((Vector3)nnInfo_Start.node.position, (Vector3)nnInfo_End.node.position, OnPathComplete);

How are you adding the connections? I suspect that you may only be adding uni-directional connections instead of bidirectional ones.

We are only using uni-directional connections because we are building a Driving-Simulation. So each lane of a street can only have one direction.

int numNodes = listAStarNodes.Count; // this is the list where we hold our own nodes

    AstarPath.active.AddWorkItem(new Pathfinding.AstarWorkItem(ctx =>
    {
        Pathfinding.PointGraph graph = AstarPath.active.data.pointGraph;
        
        for (int i = 0; i < numNodes; i++)
        {
            GameHelper.Node tempNode = listAStarNodes[i];
            Pathfinding.PointNode bla = graph.AddNode((Pathfinding.Int3)(new Vector3(tempNode.x, tempNode.y, tempNode.z)));
        }

        for (int i = 0; i < numNodes; i++)
        {
            GameHelper.Node tempNode = listAStarNodes[i];
            int numNeighbors = tempNode.getNumNeighbors();

            for (int j = 0; j < numNeighbors; j++)
            {
                int neighborIndex = tempNode.getNeighbor(j).normalNodeIndex;

                
                
                    
                    graph.nodes[i].AddConnection(graph.nodes[neighborIndex], (uint)(graph.nodes[neighborIndex].position - graph.nodes[i].position).costMagnitude);                                                
                
                
            }
        }

        
    }));

    AstarPath.active.Scan();

Ah, I see.

There is one case where the package can become very confused. Given two nodes A and B, assume there is a valid path from A to B but not from B to A (for example a dead end). This may confuse the system and it may cause it to discard paths from A to B as not possible as well.
This is due to a subsystem which groups nodes into connected components (https://en.wikipedia.org/wiki/Component_(graph_theory)). Unfortunately that only works if the connected components are well defined, which they are not for that kind of graph.

You can disable this subsystem to make this work:

  1. Open the HierarchicalGraph.cs script
  2. Find the FloodFill method and insert a return' statement at the top of that function so that nothing in the function runs.

Also, something which may be useful to know: the system draws one-drectional connections by only drawing half of the connection line. So if there is a line from A to the midpoint between A and B that means there is a connection from A to B but no connection from B to A.

Hi

I can’t thank you enough. It works. All paths are calculated correctly.
Maybe a checkbox would be useful so that the modification of the source code is’nt necessary anymore.

Lets hope that a build for PS4 and XBox will make no problems.

Greetings
Thomas

1 Like