2
\$\begingroup\$

I am working on carrom like game using cocos2d + Box2D. I set world gravity(0,0), want gravity in z-axis. I set following values for coin and striker body:

Coin body (circle with radius - 15/PTM_RATIO):

density = 20.0f;
friction = 0.4f;
restitution = 0.6f;

Striker body (circle with radius - 15/PTM_RATIO):

density = 25.0f;
friction = 0.6f;
restitution = 0.3f;

Output is not smooth. When I apply ApplyLinearImpulse(force,position) the coin movement looks like floating in the air - takes too much time to stop.

What values for coin and striker make it look like real carrom?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ For anyone that doesn't know the game: en.wikipedia.org/wiki/Carrom \$\endgroup\$
    – Ray Dey
    Nov 28, 2011 at 12:12
  • 4
    \$\begingroup\$ Study some physics and figure it out mathematically. (Worth having some general knowledge in that area anyway if you're a game developer) \$\endgroup\$ Nov 28, 2011 at 23:00
  • \$\begingroup\$ @Jonathan Hobbs Not really fair as the issue here is related to the library and no amount of correct math would fix the problem out side of making his own engine, \$\endgroup\$ Feb 9, 2012 at 23:42

2 Answers 2

3
\$\begingroup\$

Box2D comes with a FrictionJoint. From the docs:

The friction joint is used for top-down friction. The joint provides 2D translational friction and angular friction.

As far as I know it doesn't really matter what you attach your physics-bodies to (using the joint). So you could attach them all to a border of the play-board and tweak the friction/torque settings until it looks realistic.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Removed my answer because the friction joint is the best way to go about this. \$\endgroup\$ Feb 10, 2012 at 6:19
1
\$\begingroup\$

Use setDamping. It acts as air resistance.

object.setDamping(10.4);
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .