How do i make NPC "herds"

So basically, im making this shooter game, however, I want this type of enemy to stick together in groups and attack the player together, any way this could be done?

The basic idea in my mind is that you assign a groupname to each npc and make it so that the group goes to the same point that being the player or infront of the player but their position would be a bit randomised based on their number.

Look into the boids algorithm. You can do it in 2d first, then use that 2d as a top-down view of the enemies.

Iā€™d consider it to be an intermediate difficulty task. Key is to start with 2d, and only when that is working move to 3d. Simplify for easier solving.

2 Likes