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 am designing a simple billiard game with box2d. I think I can easily simulate hitting left or right side of a ball. Since box2d is not 3D, however, I am not sure how to simulate hitting upper or lower part of ball with a cue.

In case you are not familiar with the game. If the ball is hit on its upper part, it's still going forward after hitting another ball. But when cue hit on its lower part, it should backspin as soon as striking another ball.

Is this simulation possible with box2d? If so, a hint or reference will be appreciated.

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

First off; I am not familiar with box2D and may not have the right terminology for physics. But storing the top/backspin should be as simple as storing a 2d vector for the potential velocity the ball is "carrying" from when the spin started. Then on collision detection you perform the normal collision and after that you apply the spin. Some tweaking would be required to make it feel right.

Also though, top/backspin affects the balls trajectory depending on how much grip the ball has, correct? So you would probably need to add code for each simulation step to check how much velocity it would transfer depending on the balls current velocity and the friction between the ball and the table.

Hope it helps.

share|improve this answer
2  
That's pretty much exactly it. Box2D is a 2D physics engine; it won't automatically handle friction against a table 'behind' the playing field, and it has no way to represent rotations relative to it. So you end up having to fake it in a manner like the one that Daniel describes, or else use a fully 3D physics engine, such as ODE or Bullet. –  Trevor Powell Jan 22 '12 at 9:03
1  
Yep, you need to use custom collision hooks that Box2D provides. Check the manual, @Paul. –  Nick Wiggill Jan 22 '12 at 11:24
add comment

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.