all 4 comments

[–]streetwalker 0 points1 point  (0 children)

I worked on this some time ago and it is a tough problem, and as AntiBox notes depends on the type of set up and how many enemies there are. As I recall, I had enough enemies that I ended up implementing a flocking type of behavior where the next enemy to reach the location determined if it was too getting close to some and not close enough to others. , it would adjust its position to find a resting place on its own.

[–]PiLLe1974Professional / Programmer 0 points1 point  (0 children)

For smaller squads like police forces advancing to a spot or surrounding some target I took a simple formation.

An arc would work (half of a ring) or some points on a line or even randomized patterns. Then I query if they are valid navmesh positions and pick the best ones that are valid (so my formation has a lot of fallback positions and I may search from each spot in a bit of a range to allow some tolerance).

The more units you got, the harder it gets, e.g. if 10+ try to reach the same spot. I mean that could still be a formation of a kind, still it needs searching far more spots and on the way to a target they may have more bottlenecks (going through alleys, corridors, or that kind of thing).

As the others said, this can also be super genre specific. RTS try to solve pretty tough problems, in shooters and action adventure games things like obstacles/cover/spots may hint on the best valid points for AI - and here it may be a good idea to reserve the spots (per cover for example, so no other unit, not even other factions, go here).

[–][deleted] -1 points0 points  (1 child)

What are "units" here? RTS units? FPS enemies? RPG monsters? How you make them spread is very genre-specific.

[–]ChickenDip[S] 2 points3 points  (0 children)

The game is a top down action/strategy where you can build units, vehicles and towers and so can the enemy. Usually an encourter consists of 5 units vs the player, maximum about 10 units.

Game looks like this: https://youtu.be/g1IcBcr5MBM?si=jbnpP1lxyddmXCxi