Get the actual costs of a path with penalities

Hi. I am using a LayerGrid with AILerp Movement Controller and I need a way to calculate the needed actionpoints for a given Path. The easiest way would be to use GetTotalLength(), but this is just the Vector3.Distance. I expected something like path.GetPathNodes() and every PathNode has something like costs, but I can’t find a way to get the PathNodes, only List<GraphNodes>

Do I miss something?

Hi

The one that the pathfinding system itself uses is not exposed. However, you could calculate an approximation using:

uint GetCost(ABPath path) {
    uint cost = 0;
    for (int i = 0; i < path.path.Count; i++) {
        var node = path.path[i];
        cost += path.GetTraversalCost(node);
    }
    cost += (uint)(path.GetTotalLength() * Int3.Precision);
}
1 Like