4
votes

I am creating a Breakout game using Box2D (of LibGdx if anyone interest). Everything works well until when the ball hits the wall when moving with a very small angle. Please look at the image for details:

enter image description here

I tried to set the wall friction to 0 and restitution to 1, as well as the ball's friction and restitution, but it still move along the wall (I have no World Gravity, and only gave the ball a starting Impulse when it hits the paddle). This also happens to the vertical wall if the angle is small enough, it will lose X velocity.

How can I move the ball the way I expected? If there is no friction, what caused the problem?

1
It would be much easier for us if you show us some codeMekap
Checked if perhaps the ball is getting stuck in the wall?Evan Knowles
@Mekap I am currently not able to access the code, but basically, I just add 4 static bodies as walls, and ball Dynamic body, and apply Impulse when it hits the paddle. Nothing special.Luke Vo
@EvanKnowles it only happens when the angle is small enough, so I think not.Luke Vo
sounds like a rounding / type conversion issue. have you tried using float values for all your physics variables?khriskooper

1 Answers

1
votes

Try changing the velocity treshold in libgdx.

void World.setVelocityThreshold(float threshold);
float World.getVelocityThreshold();

http://www.badlogicgames.com/wordpress/?p=2030