- Home /
Controlling when enemies walk on top of each other.
Ok, I'm fresh out of ideas here. I'm making a zombie platformer. When the zombies are chasing the player, and they run into something, I have them attack it. The problem is, when I have multiple zombies attacking something from the same side, only one zombie can attack the object at the same time (its a 2D game). I want the zombies to be able to walk through each other and attack the object together, so that when there is a horde of zombies, they can get through obstacles very quickly.
The problem is, if I set the zombies so that they ignore collisions with each other, then when they stack up on an obstacle to attack it, they will all be on top of each other. Then when the obstacle is destroyed and they continue to chase the player, they will continue to walk on top of each other and they will look like 1 enemy.
An alternative is to set up a system where the zombies don't ignore collisions with each other, but rather when they stack up in a row at an obstacle, they transfer their damage to the first zombie, who then attacks with more damage (or something like that). The problem is, this doesn't give the horde effect I want. I don't want it to look like the zombies are lining up and are far away from an obstacle, but can still attack it from far away.
So I guess I really want to know is this. Is there a way to make the zombies spread out from each other, but still horde and attack an obstacle when they are attacking something.
I hope that makes sense, thanks for the help!!!
An expanding and collapsing solution - hm, what are you using as your collider agent on the zombies? A primitive or a mesh collider? If you are using a primitive like a sphere or capsule or something, perhaps you could adjust its radius up/down based on the behavior you want.
Perhaps can mitigate this problem by adding in some randomization of the movement for your enemies. Without seeing your enemy code, I cannot provide specifics, but things such as varying the speed and the path followed to a goal. Introduce some inaccuracies in the targeting until the enemies are within a certain distance to the goal. They would still collect at goal points, but would tend to spread out upon release to the next goal.
Your answer
Follow this Question
Related Questions
2D Platformer Ai Movement Decision Making Problems 0 Answers
Aggro behavior for RTS game 1 Answer
AI & pathfinding for 2D platformer - how to approach? 0 Answers
Basic enemy AI for 2.5D Platormer 1 Answer
2D 360 degress platformer example needed 0 Answers