Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've got group movement implemented pretty much like this:

http://www.red3d.com/cwr/steer/CrowdPath.html

Basically, that's combining path following and separation. It works nicely as long as units are in transit, but arrival does not work very well at all.

Right now, units just cease to use the path following component once the "exit" the path, i.e. when their closest point on the path is on or past the end.

This leads to those units bumping into each other and also overshooting the point the player clicked. Ideally, I'd have the units arrive scattered around the finish point (and reasonable close to each other), not all clumped up past the finish line.

I'd imagine that some kind of arrival steering might work here, but based on other units and a "fuzzy" classification of the end of the path.

Is there any proven way to do this?

share|improve this question
    
You want something like the way soldiers move in a RTS? –  Arthur Wulf White Oct 6 '12 at 14:28
    
Yes, this is an RTS movement question, but I already got the moving - I need the stopping without bumping into each other ;) –  ltjax Oct 6 '12 at 14:33
    
Related: gamedev.stackexchange.com/questions/28146/… –  Byte56 Oct 6 '12 at 15:59
add comment

3 Answers

  1. Shorten the last part of the path by the radius of the area the units will occupy when they stop moving. You can guesstimate this based on the 2d size of the units and their number. Increase this approximation by 1.4-1.7x to prevent overlapping.
  2. Randomize n points that do not overlap around in the destination where they will stand.
  3. Sort the points by their distance from the last point on the path.
  4. When the nth unit arrives at the end of the path, move it in a linear path to the nth most distant point in the collection you randomized and stop them. ie : The first will stand at the most distant point, the second at the 2nd most distant.
  5. You should now have them standing scattered around the destination.

In order to randomize points that do not overlap and are not organized, take the destination and split it into spots for 2 or 3n units and then remove spots randomly.

I added some images for illustration:

Units in move

enter Stopping area

Divide it to spots

randomly remove spots

enter image description here

enter image description here

share|improve this answer
    
When do you do this? Not all units might survive the trip... So I cannot plan this ahead. I need something that works a little more locally... –  ltjax Oct 6 '12 at 14:57
    
That is not necessarily true.. you just plan enough space, so basically if less units arrive that is fine. You still let the first unit take the 1st most distant spot, the 2nd, the second one and so on. –  Arthur Wulf White Oct 6 '12 at 15:06
1  
There is a problem, if soldier A goes to point (5,0) and soldier B to point (4, 0) (where 4,0 is closer to their initial position than 5,0), and soldier A is somehow delayed (slowed by some ugly, spitting creature) he will arrive after soldier B and could be blocked by him. I can't come up with a working solution to this problem different than "position soldiers loosely enough". –  Markus von Broady Oct 6 '12 at 15:28
add comment

You can combine multiple steering behaviors to get the result you want. You'll want to implement the arrival behavior. And combine it with the flocking behavior.

Select a "lead" unit. Whichever unit is in the lead works well. When you're using arrival, the arrival point for all other units in the group will be the lead unit position. The lead unit will be using the destination as it's arrival point. This will be sort of like a follow the leader situation. The lead unit will arrive at the destination and the other units will attempt to approach the lead unit.

share|improve this answer
add comment

You say you already have code to let the units avoid each other while in transit, so why not just keep that part of the code active even after reaching the goal?

In fact, to keep the units from clustering too tightly at the destination, you may want to increase the preferred separation for each unit as they reach the goal, so that they'll move out a little and give room for new arrivals.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.