how to stop enemies from moving to one point when lots of them are chasing one object

Started by
10 comments, last by alh420 10 years, 5 months ago

i am making a top down game which lots of enemies are chasing one guy.

then,enemies would move to one point without any collision,they just overlay each other.

so ,is there any simple way to make them feel more real? make them not overlay with each other?

=================================

i have a bad solution.it doesn't work well.

my solution in simple:

foreach(around_enemy_arr in other)

{

vector a = normalize(self.positionvector - other.positionvector);

self.move_vector = self.move_vector + a;

}

this can work,but when plenty of enemies come very close to each other,they would shake!!!

i am sooooo confused.

please help.

Advertisement

You may look at this Boids page. It extends Craig Reynold's original Boid algorithm. Although it targets flock simulation, it shows a rule based system where one aspect is to avoid collision like you've described, besides avoiding obstacles, predator / prey behavior, and others.

However, w.r.t. the will to live also of soldiers ;) I want to hint that it is unlikely for a soldier in the 3rd row to try to push through the own lines towards the target. Perhaps you may try to drive the closest N soldiers purposeful towards the targets, while soldiers farther away just move up when a place gets available.

Well basically you can either live with it (lots of popular games ignore it for simplicity such as World of Warcraft) or first code a barebones collision system doing distance checks and find yourself tweaking it every once so often where it needs improvement :)

You may look at this Boids page. It extends Craig Reynold's original Boid algorithm. Although it targets flock simulation, it shows a rule based system where one aspect is to avoid collision like you've described, besides avoiding obstacles, predator / prey behavior, and others.

However, w.r.t. the will to live also of soldiers ;) I want to hint that it is unlikely for a soldier in the 3rd row to try to push through the own lines towards the target. Perhaps you may try to drive the closest N soldiers purposeful towards the targets, while soldiers farther away just move up when a place gets available.

i am reading the <boids >, it really inspire mebiggrin.png

thank you!happy.png

Well basically you can either live with it (lots of popular games ignore it for simplicity such as World of Warcraft) or first code a barebones collision system doing distance checks and find yourself tweaking it every once so often where it needs improvement smile.png

i am trying to finish my simple collision system.

thank for your help.biggrin.png

lots of popular games ignore it for simplicity such as World of Warcraft

Not for simplicity, or at least not only simplicity. Ignoring player or NPC collisions prevents you from doing some AI exploits and from harrassment in the form of area-denial. Both are important in a multiplayer game.

Imagine someone manages to get a boss creature and another NPC to walk into each other so they block each other, or imagine someone standing in the bank's door so nobody can enter. Such a design is hardly acceptable.

Not for simplicity, or at least not only simplicity. Ignoring player or NPC collisions prevents you from doing some AI exploits and from harrassment in the form of area-denial. Both are important in a multiplayer game.

Imagine someone manages to get a boss creature and another NPC to walk into each other so they block each other, or imagine someone standing in the bank's door so nobody can enter. Such a design is hardly acceptable.

Thanks for expanding on it, samoth. I know all of that well but decided against more accurate wording to keep the idea brief.

Indeed what I mean by "simplicity" is that you as the coder/designer don't have to find and solve all the problems your game could get with colliding characters.

Here is another nice page about steering behaviours: http://www.red3d.com/cwr/steer/

A nice thing with those, is that you can make your game avoid the need for proper collision detection, instead it makes sure the entities stay far enough away from eachother that collision doesn't happen.

One could argue that is some kind of collision handling too, and indeed it is similar, but it is a lot more simple to implement and get right.

You never need to detect actual collisions, all you need is a simple distance check


Not for simplicity, or at least not only simplicity. Ignoring player or NPC collisions prevents you from doing some AI exploits and from harrassment in the form of area-denial. Both are important in a multiplayer game.

Ignoring Player and NPC collisions also prevents you from exploring a whole world of potential tactics in combat as well.

I'd like to add to the growing throng suggesting you work on your enemy-to-enemy collision detection first. Even though it's likely you will need to add more behavioral rules to stop the mobs bouncing off each other, this first step will be necessary no matter what else you do.

Depending on how modular your player collision detection system is, you may be able to extend or reuse it for your AI.

This topic is closed to new replies.

Advertisement