Page 1 of 1

Keeping enemies apart from each other

Posted: Thu Aug 07, 2014 1:40 pm
by eka
Hi,

I'm working on a arena shooter like game, and I was thinking on how to keep enemies apart from each other when they go to attack the player.

I was thinking on using the physics library for collision using 2 filters... one for player, player bullets vs enemy and one for enemy vs enemy, kind of a larger bounding so they keep distance from each other.

What do you think? Is using the physics lib for this a good idea? Could this be also achieved using HardonCollider?

Thanks!

:cool:

Re: Keeping enemies apart from each other

Posted: Thu Aug 07, 2014 2:50 pm
by micha
If you are using love.physics anyway, I'd say go ahead, use it. It is there already.

Beside the straight forward collision approach that you mention, there is also a method based on repulsion. Between each pair of enemies apply a repulsion force that is inversely proportional to their distance (this behavior is also called separation). That way, enemies that are close together will start moving away from each other. On the other hand, if space gets tight, this approach allows enemies to squeeze together. If you use a collision detection method straight away, then enemies will be treated like solid circles and cannot be squeezed.

Both methods do the job. Pick whatever you like better or find easier.