Hello,
I am making an RTS style game using a point graph.
I spawn in an enemy and he wants to attack the nearest allied building.
So I find all allied buildings and calculate paths for each then sort by shortest distance and start using that one.
I am using AIPath for movement.
Right now i am using this
foreach (var doodad in buildings)
{
Path path = ABPath.Construct(transform.position, doodad.transform.position, null);
GetComponent<Seeker>().StartPath(path);
path.BlockUntilCalculated();
options.Add(path);
}
if (options.Any())
{
var order = options.OrderBy(p => p.GetTotalLength());
ai.SetPath(order.First());
}
But I get an error saying “ArgumentException: If you calculate the path using seeker.StartPath then this script will pick up the calculated path anyway as it listens for all paths the Seeker finishes calculating. You should not call SetPath in that case.”
Thanks!