I’ve implemented a path previsualization in my turn-based tactics game. When I position my mouse cursor on a valid node, a path is drawn from my unit to the node.
The problem is that the pregenerated path and the path that follows the seeker is not always the same. Both paths are valid and equally short but I want both paths to follow the same rules every time.
Here the code for the pregenerated path (summarized):
var pathLine = ABPath.Construct(startWorldPosition, MouseWorld.GetPosition(), null);
AstarPath.StartPath(pathLine);
AstarPath.BlockUntilCalculated(pathLine);
lineRenderer.positionCount = pathLine.vectorPath.Count;
for (int i = 0; i < pathLine.vectorPath.Count; i++)
{
lineRenderer.SetPosition(i, pathLine.vectorPath[i] + offset);
}
And here is the seeker code in my move script:
seeker.StartPath(transform.position, destination, OnPathComplete);
The starting and end positions are the same in both cases, and I’d assumed the paths will be identical, but that’s not the case.
Thank you in advance!