Support Forum

[Pro Version] getting the index of a node from the result path


I am adding to a PointGraph some nodes and their connections to other nodes.
Searching a path from a node to another node works very well.
So far so good.

The problem is the result in OnPathComplete(Pathfinding.Path p).
I am getting only the positions of the result path. Is there a way to get the index number of the nodes which are part of the result path? The index number of a node in the result path MUST be the same index number of this node in the PointGraph.

Currently i am doing it this way:

int numPositions = p.vectorPath.Count;
for (int i = 0; i < (numPositions - 1); i++)
var nodeStart =[i]).node;
var nodeEnd =[i + 1]).node;

int nodeStartIndex = nodeStart.NodeIndex;
int nodeEndIndex = nodeEnd.NodeIndex;


Is this correct?



The path field of the path object contains all nodes.

foreach (GraphNode node in p.path) {
    var pointNode = node as PointNode;