Keeping enemies apart from each other

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
eka
Prole
Posts: 5
Joined: Mon Aug 04, 2014 3:00 pm

Keeping enemies apart from each other

Post 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:
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Keeping enemies apart from each other

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests