This project has moved and is read-only. For the latest updates, please go here.

The way things bounce when they collide

Topics: Developer Forum
Oct 4, 2009 at 5:33 AM
Edited Oct 4, 2009 at 5:34 AM

I am attempting to make a simple pong game and am having some issues with the direction in which the ball moves after a collision with a paddle or boundary. Usually it works fine but sometimes there is a weird bounce here and there that I want to try to fix. In the following (crudely drawn) images, in green is the path the ball normally takes when it bounces off something and the red are those weird bounces it does once in a while. Any way to fix that? Thanks a lot : )


Image and video hosting by TinyPic Image and video hosting by TinyPic

Oct 4, 2009 at 2:39 PM

Try setting the moment of inertia to infinity, i.e.

body.MomentOfInertia = float.MaxValue; (something like that)

Oct 4, 2009 at 8:03 PM

Tried that, no luck. Thanks for the idea though.

Oct 4, 2009 at 9:15 PM

Do you have one or several balls?

You have the weird reactions because circles are not circles, they are approximations of circles. If you have a single ball, you can hack your way of of that problem completely by using a circle that has a point on top, bottom, left and right (you can even use a square). and disable rotations on the geometry. (like sterlingware suggested).

Oct 4, 2009 at 9:51 PM

Only one ball and that worked great. Thanks a lot. both of you : )