The Daily Click ::. Forums ::. Klik Coding Help ::. Top Down Shooter - Creeps bunch up on top of one another
 

Post Reply  Post Oekaki 
 

Posted By Message

Avantar1975



Registered
  01/12/2011
Points
  39
2nd July, 2012 at 02/07/2012 19:09:15 -

This seems to be such a noob question that I can't seem to find it being a problem for anyone else.
(Hope someone is willing to help)

Here's what I've got: I've got a spawnpoint where 5 creeps spawns from at a time. They go on top of one another when attacking stuff like bases and so forth. So I have tried "when creep collides with itself, then bounce"
That messes stuff up completely so that they scatter in all directions.
The creeps have a "bouncing ball" movement with a speed of 10 and just goes their merry way to its target (the enemy base)

Is there some other method to prevent them from climbing on top of one another?

Thank you in advance.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
2nd July, 2012 at 02/07/2012 21:10:03 -

Maybe have the game choose one of the creeps, and move it in a random direction until it's not overlapping anymore.

Another idea is to spawn one Enemy at a time, but stagger the spawning so that another Enemy will spawn only if a creep isn't already overlapping a spawn point. Each time an Enemy spawns, add to a counter or Alterable Value, and if the counter hasn't reached 5 yet, spawn another Enemy. Reset the counter to 0 whenever you want to spawn another group of 5.

It would take a little work to make sure the event structure works, and unfortunately I'm not at my MMF machine at the moment. I'll see if I can come up with an example of the above. If no one else has solved it for you by then, I'll post it here.

In any case...good luck!

 
n/a

SolarB



Registered
  26/12/2011
Points
  564
3rd July, 2012 at 03/07/2012 04:22:36 -

Self-avoidance is one of the trickiest things to implement in MMF, so your question isn't as noob as you might think!

Here's my solution:

http://dl.dropbox.com/u/22580256/creepoverlap.mfa

It's crude and not the best but by far the least complicated of others that I've seen. Usually this kind of thing involves expensive distance calculations or pathfinding.

But if you're up for it your best bet would be to use Box2D, like in this example:

http://www.create-games.com/download.asp?id=8087

 
My Open Source Examples: http://bit.ly/YyUFUh

SolarB



Registered
  26/12/2011
Points
  564
3rd July, 2012 at 03/07/2012 04:48:28 -

here's a quick Box2D example:

http://dl.dropbox.com/u/22580256/creepbox2d.mfa

 
My Open Source Examples: http://bit.ly/YyUFUh

Avantar1975



Registered
  01/12/2011
Points
  39
3rd July, 2012 at 03/07/2012 10:53:21 -

Thank you so much for all the replies. I will check it out.

To s-m-r: I do have my creeps spawn one at atime with a counter of 5 being deducted 1 from it every second as the creeps spawn. I think what can contribute to my problem is the way I move the creeps around obstacles. I struggled with advanced path finding and so I made waypoints on the board and use distance calculations. Overlapping the waypoint sends the creep in the direction it needs to go. It kind of works, but the intelligence of the creeps is not all there and bounce is a no-no. So I have conditions for following an enemy, fighting and following waypoints by altering an alterable value. I do spread alt. C value of creep, but I sometimes get the notion that it doesn't always know which creep is which.

To the rest that replied. I do appreciate and will have a look at the suggestions. I will let you know as soon as I can.

 
n/a

Avantar1975



Registered
  01/12/2011
Points
  39
3rd July, 2012 at 03/07/2012 11:02:57 -

Hey SolarB..
I have checked out your examples and it rocks! Box2D looks a bit senior to me
I am going to try your easy solution. It might also be worth while to change the way my creeps find their way- a bit of studying advanced pathfinding might help.

Thanks again.

 
n/a

hapsi



Registered
  13/11/2003
Points
  775
3rd July, 2012 at 03/07/2012 11:19:55 -

I have a "collision shield" on each npc in my project(top-down too). Its a little larger active than the actual npc. In addition there is bounce limiter and when it reaches certain value (bounces) npcs stop for a while. Works fine.. could be better.
Usually the siplest works the best as in example before. I hadn't even thought that.

Edited by hapsi

 
[Signature][/Signature]

Avantar1975



Registered
  01/12/2011
Points
  39
3rd July, 2012 at 03/07/2012 22:33:11 -

Ok..so here we go: This is my first attempt at a full fletch game and it goes kinda slow.

I got fed-up trying to figure out advanced pathfinding and so I stuck to my waypoint system. I have uploaded a taste of what I'm doing here:
http://www.mediafire.com/download.php?61ibl2lb3di4bb4

I haven't done all the waypoints on the map yet, but this is what is happening:
1) The creeps follow the waypoints to the enemy base and start attacking when it reaches the base.
2) When a player moves closer than 75 pixels to one of the creeps, the creep follows. (try this on bottom and right side of the map - haven't put waypoint in middle-left or top left - default control for player1 is the joystick; since it got minor force feedback effects - disregard player 2)
3) Did the creep overlap thing the easy way, but not for the base - area is a bit small.
4) If a creep gets out of range when following a player it will go to the nearest waypoint and follow its path again

It is actually a single player/co-op game that I'm busy with, but thought it might be fun to include a 2p and 4p versus game.

PS. Keep the fire button pressed in and move around to strafe, single fire not really effective in this game. Thank you all for the help.

 
n/a

nivram



Registered
  20/07/2006
Points
  171
4th July, 2012 at 04/07/2012 16:30:20 -


Originally Posted by hapsi
I have a "collision shield" on each npc in my project(top-down too). Its a little larger active than the actual npc. In addition there is bounce limiter and when it reaches certain value (bounces) npcs stop for a while. Works fine.. could be better.
Usually the siplest works the best as in example before. I hadn't even thought that.



Hi hapsi. Any way that you can do a quick example for me/us?

Thanks

Marv

 
458 MMF2 & CTF 2.5 examples and games

http://www.castles-of-britain.com/mmf2examples.htm
   

Post Reply



 



Advertisement

Worth A Click