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

I have a Box2D project that is about to create a view where the user looks from the Sky onto Water. Or perhaps on a bathtub filled with water or something like this. The Object which holds the fluid actually does not matter, what matters is the movement of the bodies, because they should move like drops of grease on a soup, or wood on water, I can even imagine the the fluid is mercurial, extreme heavy and "lazy".

How can I manipulate the bodies (every frame or time by time) to make them move like this?

I started with randomly manipulation their linear velocity, but I turned out that this not very smooth and looks quite hard.

Is it a better idea to check their velocity and apply impulses? Is there any example?

Greetings philipp

share|improve this question
up vote 4 down vote accepted

If you are describing a top-down, or bird's eye, view, then the solution is simple. Fill your scene with dynamic objects and do not apply gravity to the world at all (set gravity to 0). Then, each update step in your game loop (but never during b2World.step()), apply a force or impulse. This will set them in motion and Box2D will take care of the rest. If you want them to not continue moving forever, set some damping (probably a higher damping for a thicker fluid). This will allow them to slow and come to rest until you apply more forces to them. The rest is just art.

share|improve this answer
you are right, totally I am quiet sure now (that is why accepting needed time). Some Damping and some Impulses did the trick. – philipp Sep 19 '12 at 13:23

You might want to take a look at some buoyancy examples for box2d.

some info: b2BuoyancyController

share|improve this answer
Thanks! I have already seen this, its cool, but my view is from from the the top onto the surface of the fluid, so this is a sideview... Or can I use it for a topview too? – philipp Sep 18 '12 at 5:58

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.