Page 1 of 1
Top-down objects never rest
Posted: Fri May 01, 2009 10:05 pm
by allenp
Hi,
I'm trying to make a top-down pool game. Everything is going great, but my circles never seem to want to rest. Is there an attribute/setting that specifies a minimum speed that objects rest at? Should I just loop through all my objects each tick and rest those that are going slow enough? How do I manually rest a body?
An unrelated question - any brainstorms for the best way to detect if the ball is over the pocket? Put another shape on a different layer and figure out what % of overlap there is?
Thanks!
Patrick
Re: Top-down objects never rest
Posted: Sat May 02, 2009 7:23 am
by allenp
I've figured out some of my question - I had used the grabbed example and their damping was in the accelerometer code (which I figured would be called so I left it there). It works much better in the init

I set damping to 0.5 and it seems pretty good.
Re: Top-down objects never rest
Posted: Sat May 02, 2009 8:50 am
by maximile
allenp wrote:An unrelated question - any brainstorms for the best way to detect if the ball is over the pocket? Put another shape on a different layer and figure out what % of overlap there is?
You could make a circle collision shape in the middle of the pocket, but subtract the radius of the ball from the radius of the pocket when setting the radius of the collision shape. That way you'll get a collision when the centre of the ball is over the pocket.
Re: Top-down objects never rest
Posted: Sat May 02, 2009 11:12 am
by slembcke
You could use a collision callback, but I'd probably just iterate the list of balls after every frame and check if they are close to the center of any of the holes. It would end up being like 10 lines of code maybe and slightly simpler than setting up collision callbacks and whatnot.
Re: Top-down objects never rest
Posted: Sat May 02, 2009 4:04 pm
by allenp
In case anyone was curious - I ended up using a collision callback and checking to see if the center of the pool ball was within the circle of the pocket. If it was I applied a force to the ball towards the center of the pocket, and then if both their centers were within a certain distance, I "sunk" the ball.
Thanks for such an easy to use physics framework! The collisions were really easy once I saw some examples.
Re: Top-down objects never rest
Posted: Sat May 02, 2009 4:04 pm
by allenp
In case anyone was curious - I ended up using a collision callback and checking to see if the center of the pool ball was within the circle of the pocket. If it was I applied a force to the ball towards the center of the pocket, and then if both their centers were within a certain distance, I "sunk" the ball.
Thanks for such an easy to use physics framework! The collisions were really easy once I saw some examples.