Collision: Ball vs Multiple Blocks side by side

Aug 22, 2009 at 12:28 PM
Edited Aug 22, 2009 at 1:19 PM

One ball 30 pixels in diameter, 20 blocks all 30x30 pixels in size. The blocks are side by side, touching, forming a horizontal line like the bricks in Mario.

The ball is dropped onto the blocks, and steadily stables itself. Works great so far..

Applying an impulse to the ball to move left or right, results in somewhat smooth rolling across these blocks.. but about 1 in every 3-5 blocks results in the ball supposedly hitting a corner of one of the blocks.That makes the ball bounce for what (to the user) seems like no reason at all.

My only real guess at the moment is that I need to use odd width/height sizes so the center location of the ball/blocks is a pixel in itself, so there aren't any rounding issues. That sound about right?


Thanks for any and all help,



Edit: My assumption was incorrect, so.. yeah.

Aug 22, 2009 at 1:39 PM

I bet you might try something with the friction I remember reading in the manual about the settings.  Let me know what you find as I'm sure I will come to an issue like this in the future.

Aug 22, 2009 at 2:32 PM

So far, friction doesn't seem to change anything and neither does it have to do with rotation of the ball.

I even changed the ball to just a solid square, like the tiles I have horizontally spread, and it doesn't slide across them properly either. You get going over the first few just fine, and all a sudden your sprite is flying through the air spinning like mad.

I can overlap the tiles, separate them 1/2/3 pixels apart from themselves, disable their own potential collisions with one another, yet I always end with the same results.

Aug 22, 2009 at 2:38 PM

This is a known problem for this type of physics engine. I believe it happens when a corner hits another corner and the bias is towards the vertical edge rather than the horizontal edge. This causes the geometry to jump a little. It might be minimized by increasing the accuracy of the simulator (increase PhysicsSimulator.Iterations).

Else you have to work around it by using rays. It really depends on your game, but a hack/workaround is in order to fix this in your game.