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 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
add comment

2 Answers

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
1  
If my answer helped you, consider accepting it (click the check mark to the left). Your accept rate is low and people may not want to answer your questions in the future. Thanks and good luck! –  Amplify91 Sep 18 '12 at 2:33
1  
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
add comment

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

http://personal.boristhebrave.com/project/b2buoyancycontroller/demo

some info: b2BuoyancyController http://personal.boristhebrave.com/project/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
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.