Should my ball ever stop rolling?

Official forum for the Chipmunk2D Physics Library.
Post Reply
pragmojo
Posts: 1
Joined: Thu Apr 12, 2012 3:42 pm
Contact:

Should my ball ever stop rolling?

Post by pragmojo »

I'm working on an iOS game where you launch balls, and try to get them to hit a target. The issue I'm having is that once balls stop bouncing, they appear to keep rolling forever at a constant velocity no matter what I set the friction and elasticity to. Is this the expected behavior? If not, what can I do to make it slow down and stop like a real-life ball?

Thanks in advance
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Should my ball ever stop rolling?

Post by slembcke »

They shouldn't. What you want is rolling friction, which Chipmunk does not provide automatically.

You can fake it by attaching a cpSimpleMotor joint between your ball and the staticBody with a rate of 0 and a maxForce of the amount of rolling friction you want. This will give you the effect you want. It won't take the normal force into account (like if something was stacked on it), but I don't think anybody would notice that.

If you want to get fancy, attach the joint in a collision begin callback with the ground and remove it in a separate. That way it won't also apply the rolling friction while the object is in the air.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 11 guests