Fun with antigravity
28 January 2014
Some time ago, I needed a simple crowd algorithm for a project of mine.
In that project there was a bunch of entities, which were moving towards
a common target. Everything was alright until those entities were close
to the target and each other - every entity was placed at the target at the same point.
I've tried to implement some collision detection for every entity, so if one entity
detected that it is colliding with another one, it would stop moving and wait for
the second entity to go away. But, when there would be multiple entities in close
proximity - then almost everyone would wait for everyone.
The solution for a simple, almost dumb crowd simulation was very close. Every enitity,
instead of stoping and waiting, should apply a revese force which would depend on the
proximity to a near entity. That approach is the opposite effect to gravity - antigravity.
The result of this algorithm can be seen above, with some presets for particle behaviors
from a "crowd", "jelly" to "bacteria". Such a simple solution can create a great range of
posibilities. Of course this is not near a full blown crowd simulation with advanced
agent AI, but for my small project, the antigravity did a great job.