Crowd control using collisions

Currently my ‘game’ has a bunch of monsters in a tilebased environment. They are able to pathfind nicely using A* and so forth, but lacking crowd control they tend to pile up on top of each other in the same space. For the past few weeks I’ve been trying to figure out a solution for this problem.

Initially I tried the CollisionHandlerPusher which does a decent job at keeping them apart. The problem with pusher alone is that it has a habit of pushing the monsters through walls into bad areas, but I can’t afford to have collision checks against walls since there are so many of those and they’re procedural. In addition the pusher doesn’t give an opportunity for more ‘intelligent’ behaviour either such as waiting for a new route to open up or to even start standing still.

I’ve also tried dynamically switching places in the A* map as unpassable as each monster moves around, but that didn’t work very well either. Most recently I attempted to have the monsters stop if they encounter another monster that’s already attacking the player, but I just couldn’t create a reliable system by combining pusher and queue (often the collisions didn’t seem to register in the queue, just for the pusher).

I am sure the Panda collisions can provide a sufficent solution to my problem, but I’m a bit out of ideas how to implement a functional and efficent logic using them (I may have up to 50 monsters roaming at one time toward the player). So in a nutshell I need some kind of logic for preventing the monsters from entering each other (currently they have CollisionSpheres for detection), stop from trying to go through each other and to try again when a comrade is no longer blocking the way.

The answer is probably more simple then it seems as I’m not looking for any fancy AI routines such as finding a free route to travel behind the players back etc. Any ideas are welcome. :unamused: I’ve tried reading some of the stuff linked at gamedev, but with no real success there either :blush:

Collision with walls can be optimized see my eggoctree script.
But if your game is tile based you should seek tile based solutions.

You could have a look at steering behaviour (flocking, obstacle avoidance) if you want to put the AI inside the monster.

If you want to put the AI inside the landscape,you can use a grid of your world with a scent based behaviour.
Friends are sources of positive population scent.
Nme are sources of negative population scent
Goal are sources of goal scent…

Each cell decay each type of scent by a fixed factor…
Obstacle do not diffuse any scent
Friends does not diffuse the goal scent
Nme does not diffuse the goal scent

So each cell have a value provided by the neighbour cells
and the ai tick is simply to follow the ascending gradient

Your choice :slight_smile: