Hello! My question is best explained through the following scenario:
There are 10 enemies that reach an intersection where their hallway splits into 2 (that later both converge into my position). If I am slightly closer to the left they will all go in that direction. I do not like how this looks, and adding some variation would make the enemies less predictable.
How can I intentionally avoid situations like this, where enemies will still take a clean path to their target but not necessarily the shortest and not all the same?
Sorry for the late answer.
There is a modifier called the AlternativePath modifier which you could try to use. It is quite old though and it might not give you the effect you are looking for.
Another approach is to assign different tags to all nodes and then have different agents assign different weights to those tags.
For example
AstarPath.active.AddWorkItem(new AstarWorkItem(ctx => {
var gg = AstarPath.active.data.gridGraph;
for (int z = 0; z < gg.depth; z++) {
for (int x = 0; x < gg.width; x++) {
var node = gg.GetNode(x, z);
// This example uses perlin noise to generate the map
node.Tag = Mathf.PerlinNoise(x * 0.087f, z * 0.087f) > 0.4f ? 1 : 0;
}
}
}));
The above code will assign different tags to the nodes in a way that adjacent nodes usually have the same tag (it’s a bit blob-like). The code is re-used from this example which you can also see an image of it: https://arongranberg.com/astar/docs/graphupdates.html#direct
Then in the Seeker settings you can assign different penalties for different units. For example one agent might have a penalty of 1000 for traversing tag 1 and 0 for traversing tag 2, and another agent might have a penalty of 0 for traversing tag 1 and 400 for traversing tag 2. This will cause the agents to take slightly different paths.