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 setup a simple simulation environment something like billiards. There are four circle balls (dynamic) and four box walls (static).

Simulation works... except one thing. Sometimes when a ball rest against a wall, it sticks to the wall eternally. The other balls hits the stuck ball so many times, but the ball never wants to separated with the wall. The only situation where the ball will become unstuck from the wall is another if another ball is rests against the same wall such that it hits the already-stuck ball.

Why does this situation occur? How can I avoid it?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Try changing b2_velocityThreshold variable in b2Settings.h - this setting keeps the simulation stable by ignoring tiny bounces but that's probably not what you want in a billiards game.

share|improve this answer
    
You're right. The parameter was exactly what I have been found. Anyway, I have discussion already here: gamedev.stackexchange.com/q/12003 Thank you for answering :) –  Eonil Aug 2 '11 at 5:55

Most likely, you have collision resolution code that reverses (reflects) the direction that the ball is going when it hits the wall. If the ball's position penetrates the wall slightly and stays there until the next frame, it may sense a collision again be reversing direction again (and each frame thereafter) and stay stuck.

Typically, if you sense a collision with the wall, in addition to reflecting the ball's direction, you should also make sure you position it on the side where it won't sense a collision next frame.

share|improve this answer

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.