Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Age of Mythology and some other strategy games, when you select multiple units and order them to move to some place, they make a "group" when they reach the desired location:


I have a Vector with several sprites, which are the selected units, the variables tarX and tarY are the target x and y. I just want an example, so you can just set the x and y position and I can adapt it to my code. Also, I would like to ask that the algorithm calls "isWalkable" for the x and y position, to determine if it's a valid position for each unit.

share|improve this question
up vote 5 down vote accepted

What you're looking for is basically coordinated movement. The units pathfind to their destination and when they reach it, they form a "formation".

This is a topic decently covered in the AI Game Programming Wisdom (Book 1, Book 2, Book 3 and Book 4) books. But, I'll refer you to the following articles:

Coordinated Movement - A link explaining the fundamental principles of coordinated unit movement in RTS games


Implementing Coordinated Movement - An article continuing from the first, that talks about how to implement this type of movement in a game.

It's written in C++ but it shouldn't be too difficult to port to any other language, as the underlying principles remain the same.

Hope that helps.


share|improve this answer
Okay, I'm gonna read it. I am using A* path finding. – user4248 Dec 27 '10 at 21:00

Your Answer


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