Jump to content
  • Advertisement
Sign in to follow this  
wulallala

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

This topic is 2072 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

 

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.

Share this post


Link to post
Share on other sites

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

Edited by Olof Hedman

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!