Function ABPath.FakePath

FakePath (List<Vector3> vectorPath, List<GraphNode> nodePath=null)

Creates a fake path.

Public Static
ABPath FakePath (

List<Vector3>

vectorPath

List<GraphNode>

nodePath=null

)

Creates a fake path.

Creates a path that looks almost exactly like it would if the pathfinding system had calculated it.

This is useful if you want your agents to follow some known path that cannot be calculated using the pathfinding system for some reason.

var path = ABPath.FakePath(new List<Vector3> { new Vector3(1, 2, 3), new Vector3(4, 5, 6) });

ai.SetPath(path);
You can use it to combine existing paths like this:

var a = Vector3.zero;
var b = new Vector3(1, 2, 3);
var c = new Vector3(2, 3, 4);
var path1 = ABPath.Construct(a, b);
var path2 = ABPath.Construct(b, c);

AstarPath.StartPath(path1);
AstarPath.StartPath(path2);
path1.BlockUntilCalculated();
path2.BlockUntilCalculated();

// Combine the paths
// Note: Skip the first element in the second path as that will likely be the last element in the first path
var newVectorPath = path1.vectorPath.Concat(path2.vectorPath.Skip(1)).ToList();
var newNodePath = path1.path.Concat(path2.path.Skip(1)).ToList();
var combinedPath = ABPath.FakePath(newVectorPath, newNodePath);