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

pong (yes I know...)

Apr 8, 2011 at 6:05 PM
Edited Apr 8, 2011 at 6:06 PM

Hello all.

Yes I have a Pong question. This must be too simple for you guys but apparently it's not for me :(.

I have a paddle (dynamic rectangle body) and a ball (circle body). On the edges of the paddle are static wall bodies to prevent the paddles and ball from leaving the screen.

The problem is of course that the paddles are being pushed back by the ball.

I tried:

A: Give the paddles an astronomical high mass compared to the ball's mass.

Result: It doesn't work because when the ball is squished between a paddle and a wall the paddles are still moved left/right.

B: Manually set the paddle's bodies X-position back every Update-cycle

Result: It solves the problem for the paddles but with this approach the ball starts behaving strange upon contact with the paddle.

C: Manually set the paddle's bodies LinearVelocity.X back every Update-cycle.

Result: The same as B.

D: Use a static body for the paddle

Result: I didn't even try this. Obviously this will cause problems when the ball is squished between the paddle and the wall.


I read the discussion on:  but none of the solutions worked for me and the last solution offered doesn't work in the latest FPE I think because there are no more geoms+bodies.


This must be soooo easy. Can anyone please enlighten me?

Apr 8, 2011 at 11:10 PM

Kinematic body types does not move upon impact. You could experiment with that.

Apr 9, 2011 at 8:38 AM
Edited Apr 9, 2011 at 8:38 AM

Thanks for your reply.

Making the paddles kinematic solves all problems but one. This still makes the ball go through the paddle/wall when the ball is squished between the paddle and the wall. This is logical FPE behavior I suppose because the paddle is kinematic, the wall is static, and the ball is dynamic. So the ball has no place to go while the paddle and the wall are closing in on each other. But it is not exactly a desired effect.

I could make the paddle very thin but the problem can still occur. This would only decrease the chance of it to happen.

Apr 9, 2011 at 3:57 PM

Do you really need the ball to go behind the paddle? I would think that would be an end condition that would do something to avoid the issue altogether. Once the ball touches the axis the paddle is on you could freeze the paddle or removed the ball. Either of those would work around this problem.

If that doesn't work you could set IsBullet to True on the ball's body. That is supposed to help prevent penetration issues like this.

Or maybe you could handle the OnCollision and OnSeparation for the paddles. Then when they collide with the ball freeze them and unfreeze them when they separate. It might be noticeable but it's worth a try.

I think the root of the problem here is that you are introducing an unstoppable object (the paddle) into the physics. unstoppable objects just don't exist in the real world so of course you get a result that doesn't make sense. You have to put some sort of limit on it.

Apr 9, 2011 at 4:50 PM
Edited Apr 9, 2011 at 4:50 PM

I was actually hoping that the FPE could somehow prevent the paddle from squishing the ball into the wall/paddle.

But I guess that  the best solution is to remove the ball as soon as it touches the paddles y-axis then. But when the ball hits the paddle on the corner it will also be removed as it then slightly hits the paddles y-axis too. I can make some workaround for that.