-5
\$\begingroup\$

Possible Duplicate:
two balls stick together in a pool game?

I have problems in circle circle collisions in a pool ball game..

The game has problems like the circles (or balls) stick together: they overlap after collision. I tried changing the directions after collisions and it works well, but when I arrange the balls real close and then the striker ball is shot at high velocity towards any of the balls, the balls start overlapping again, and also the striker ball slides over the hit balls.

What could be the reason for this and how could I fix it?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ How many times are you going to ask the same question without providing any specifics that might help us help you? \$\endgroup\$ Commented Aug 10, 2010 at 11:32
  • \$\begingroup\$ Vishnu Ajit: How do you resolve collisions? If ball A collides with ball B and either balls get moved you have to make sure to resolve any collisions (and detect them) that the balls might cause from moving after the collision... if that makes sense. \$\endgroup\$ Commented Aug 10, 2010 at 12:54

2 Answers 2

2
\$\begingroup\$

Honestly, I would just use a physics library. It saves a lot of trouble in the long run, especially with respect to collision response.

\$\endgroup\$
1
\$\begingroup\$

Did you remember to abort moving the ball if you predict a collision when moving to the new location?

What you might be doing is that you're actually moving the ball first, then checking if it has collided.

If you check for collision, then move the ball you should avoid these overlapping cases.

Assuming you're checking for collision often enough.

\$\endgroup\$
1
  • \$\begingroup\$ It does sound like he moved first. Then, while inter-penetrated past mid-point, he calculated a new velocity (in roughly an opposite direction) which did not have the speed to separate them by the next frame, which again reversed direction, which didn't make it out... etc...etc... balls stick together. @Vish: If you move first, you must remove penetration before calculating new velocity. Better yet, google, & implement quadratic equation which solves exact point of contact, then calculate new velocity from there. One of these threads should not have been closed... it is a common noob problem. \$\endgroup\$ Commented Sep 1, 2010 at 14:52

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.