Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

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

If that is even what it is called. What I am trying to do it:

Can someone please point me to towards a book or in vaguely the right direction? I don't even know where to start or what physics/maths to read about?

share|improve this question
up vote 3 down vote accepted

What you're looking at is called a force-directed graph. Google for that and you should find some helpful documentation. The math is surprisingly straightforward.

share|improve this answer
You are my hero! I can't even begin to tell you how many hours of my time you have saved. – Duncan Edwards Dec 8 '10 at 17:46

Vector maths is a must, you shouldn't need more than the basic parts for this, but the rest is generally very recommendable for a game programmer, so if you skip the cool stuff for now be sure to get back on the topic sometime. From there you could read about ragdoll physics, though a lot of sources for that may be "heavier" than what you need, so I'll just sketch out how I presume the animation works.

It runs a set number of updates per second.
For every update it iterate over all pairs of objects.
If the objects are too close each of the two objects will be moved a little away the other.
If they are connected and too far from one another each object will be moved a little closer to the other.
In both cases, the more the distance is off, the more they should move. Try for instance moving the objects 1/10 of what they are are off the target.
It's probably best to not move the objects immediately when you do the calculation, but rather for each object sum the movement over an entire update and execute it only after the movement relative to all the other objects has been calculated.

This setup does not use velocity and acceleration as one would with common ragdoll physics, that is on purpose since the goal is to spread the nodes out nicely rather than simulate real physics.

share|improve this answer

Your Answer


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.