Reputation: 3652
If I give bodies different densities/mass, they still fall with the same speed. I know about the fact that in a place without air-resistance, mass doesn't affect falling speed.
But then, how do I logically make, let's say a balloon and a brick, fall at different speeds? The closest way I could think of is to use setGravityScale to set this all..
Upvotes: 1
Views: 959
Reputation: 1668
The best method to simulate the air speed reduction effect in box2d is to use "damping".
see: http://www.box2d.org/manual.html
"Damping is used to reduce the world velocity of bodies. Damping is different than friction because friction only occurs with contact. Damping is not a replacement for friction and the two effects should be used together."
"Damping parameters should be between 0 and infinity, with 0 meaning no damping, and infinity meaning full damping. Normally you will use a damping value between 0 and 0.1. I generally do not use linear damping because it makes bodies look floaty."
bodyDef.linearDamping = 0.0f;
bodyDef.angularDamping = 0.01f;
Upvotes: 6
Reputation: 39481
One option is to disable gravity and apply the accelerations you want each frame yourself. That's the route I went in my game. Box2d's built in gravity is ok for quick simulations, but it isn't very customizeable.
Once you've disabled gravity, you have to decide which acceleration formula to apply to your objects. There are several different models of fluid resistance (check Wikipedia), so you'll have to experiment and pick the one that looks the best.
Upvotes: 2