Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 wulallala   Members   -  Reputation: 108

Like
0Likes
Like

Posted 11 November 2013 - 07:15 AM

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.



Sponsor:

#2 haegarr   Crossbones+   -  Reputation: 4608

Like
3Likes
Like

Posted 11 November 2013 - 07:49 AM

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.



#3 ShadowFlar3   Members   -  Reputation: 1258

Like
0Likes
Like

Posted 11 November 2013 - 07:56 AM

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



#4 wulallala   Members   -  Reputation: 108

Like
0Likes
Like

Posted 11 November 2013 - 08:35 AM

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



#5 wulallala   Members   -  Reputation: 108

Like
0Likes
Like

Posted 11 November 2013 - 08:37 AM

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



#6 samoth   Crossbones+   -  Reputation: 5044

Like
0Likes
Like

Posted 11 November 2013 - 08:56 AM

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.



#7 ShadowFlar3   Members   -  Reputation: 1258

Like
0Likes
Like

Posted 11 November 2013 - 09:36 AM

 

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.



#8 Olof Hedman   Crossbones+   -  Reputation: 2958

Like
1Likes
Like

Posted 11 November 2013 - 11:11 AM

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, 11 November 2013 - 11:12 AM.


#9 jHaskell   Members   -  Reputation: 1109

Like
0Likes
Like

Posted 11 November 2013 - 02:38 PM


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.



#10 Winfield   Members   -  Reputation: 179

Like
0Likes
Like

Posted 11 November 2013 - 03:10 PM

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.



#11 wulallala   Members   -  Reputation: 108

Like
0Likes
Like

Posted 12 November 2013 - 07:26 AM

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

This is so helpful.

Thank u :D



#12 Orymus3   Crossbones+   -  Reputation: 10706

Like
1Likes
Like

Posted 12 November 2013 - 08:04 AM

Indeed collision makes the most sense.

Personally, I was faced with this issue no more than 2 weeks ago.

Instead of a strict collision system, I've created a similar behavior to collision, but instead, created what I would call "avoidance".

Whenever a collision would be imminent (distance between the active object and the collided object), the active object would change its course to "avoid" it (aka, pitch/pan its rotation/angle away from).

 

The upside is that I don't really handle collisions, which means that in some cases, two objects may be on top of one another, in such a way that movement, as a whole, is not impeded. But as a general rule, they'll try to create encirclement (find legal positions around their target).

 

Overall, it works well, and doesn't consume much process, which was the intent.



#13 Olof Hedman   Crossbones+   -  Reputation: 2958

Like
0Likes
Like

Posted 12 November 2013 - 11:41 AM


Indeed collision makes the most sense.
Personally, I was faced with this issue no more than 2 weeks ago.
Instead of a strict collision system, I've created a similar behavior to collision, but instead, created what I would call "avoidance".
Whenever a collision would be imminent (distance between the active object and the collided object), the active object would change its course to "avoid" it (aka, pitch/pan its rotation/angle away from).

 

This is pretty much how the steering behaviours work, linked to by me and haegarr. (More accurately, the "avoidance" steering)

They are pretty easy to implement, and can be combined to create quite complex behaviours, apart from just avoidance (like queueing, flocking and path following).

I highly recommend checking through the java visualizations of them.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS