In the picture below the path to the closer train stop contains more segments which leads to the longer path being chosen. This is because the pathfinder returns as soon as it reaches the segment containing the target rail end.
Blueprint for reproduction
I think the issue stems from
Code: Select all
double costFromStart = currentNode->costFromStart + currentSegment->getLength();
Code: Select all
double costFromStart = currentNode->costFromStart + neighbor->getLength();