5
\$\begingroup\$

I'm looking into building my own simple RTS game, and I'm trying to get my head around the movement of single, and multi selected units. (Developing in Unity)

After much research, I now know that its a bigger task than I thought. So I need to break it down. I already have an A* navigation system with static obstacles taken into account.

I don't want to worry about dynamic local avoidance right now. So I guess my first break down question would be:

How would I go about moving mutli units to the same location. Right now - my units move to the location, but because they're all told to go to the same location, they start to 'fight' over one another to get there.

I think theres two paths to go down:

1) Give each individual unit a separate destination point that is close to the 'master' destination point - and get the units to move to that.

2) Group my selected units in a flock formation, and move that entire flock group towards the destination point.

Question about each path:

1a) How can I go about finding a suitable destination point that is close to the master destination? What happens if there isn't a suitable destination point?

1b) Would this be more CPU heavy? As it has to compute a path for each unit? (40 unit count).

2a) Is this a good idea? Not giving the units themselves a destination, but instead the flock (which holds the units within). The units within the flock could then maintain a formation (local avoidance) - though, again local avoidance is not an issue at this current time.

2b) Not sure what results I would get if I have a flock of 5 units, or a flock of 40 units, as the radius would be greater - which might mess up my A* navigation system. In other words: A flock of 2 units will be able to move down an alleyway, but a flock of 40 wont. But my nav system won't take that into account.

\$\endgroup\$
  • \$\begingroup\$ I'm not sure if you're looking to solve this problem yourself, but Recast and Detour are two libraries that work together to solve navmesh and agent pathfinding. Specifically, the problem of moving N agents as a "crowd" is provided. At the very least, you may be able to find explanation of their solutions that spark some insight on how to solve the problem for you. EDIT: which is to say, they use option 2. \$\endgroup\$ – PatrickB May 21 '14 at 15:02
  • \$\begingroup\$ Thanks @PatrickB, Yes I am trying to solve/build this myself - just to see if I can. But thanks for your advice, I'll take a look into it. \$\endgroup\$ – Oliver Jones May 21 '14 at 15:10
2
\$\begingroup\$

You might want to take a look at these articles. They are a bit old; however I think they cover what you are looking for.

Coordinated Unit Movement

Implementing Coordinated Unit Movement

\$\endgroup\$
  • 1
    \$\begingroup\$ Link only answers are discouraged. They're useless if the links ever disappear. I suggest you expand the answer with the basic details of how to implement what the links describe. \$\endgroup\$ – MichaelHouse Sep 19 '14 at 6:31
1
\$\begingroup\$

1a) just flood from the destination depending on how many units were told to go there

1b) you can keep the path mostly along the same path and split only in the last few meters

2b) let the flock rearrange itself when squeezing past obstacles (using local avoidance of static obstacles)

\$\endgroup\$
  • \$\begingroup\$ What do you mean by flood? As in - continuously search around the original marker for a valid destination? Whilst taking into account the radius, and padding size (so the unit can actually fit into that destination). \$\endgroup\$ – Oliver Jones May 21 '14 at 15:12
  • \$\begingroup\$ yeah and use the one closest free spot and continue searching out, as if you were pouring the units onto that spot and they moved out as needed \$\endgroup\$ – ratchet freak May 21 '14 at 15:13
  • \$\begingroup\$ Okay, I do prefer the idea of using the 1st path. Seems easer to implement too. Any other things I should consider for this method? I guess with this method too, I can have specific formations at the destination end which might give a nice result. \$\endgroup\$ – Oliver Jones May 21 '14 at 15:19
  • \$\begingroup\$ Also - does this method have a specific name? \$\endgroup\$ – Oliver Jones May 21 '14 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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