Collision forces in Y direction only

Topics: Developer Forum, User Forum
Feb 4, 2010 at 6:09 AM

I have a simple game of pong going.

The problem I have is that as soon as a ball hits my paddle, the ball responds correctly to the collision, but my paddle starts flying of in different directions.

I tried setting the paddle to static, but that will not suffice since I can no longer use ApplyForce to move my paddle around.

I want to be able to move my paddle along the X axis using paddle.ApplyForce(#, #) but when a ball hits the paddle it should not have any effect on the paddle.

Any help or suggestions would be appreciated.

Feb 4, 2010 at 10:50 AM

You can create two large geoms for using them as a "rail" for your paddle:

|   |
|   |
|   |
|   |
|   |
|   |
|   |
|   |

 ^- Inside these two can be your paddle.

 

In my game I implemented an elevator, and I used this method to keep the elevator moving vertically.

Feb 4, 2010 at 12:15 PM

Haha, yeah I actually thought of that, but is there no way to tell the body or geom to just ignore vertical forces only ;

Otherwise this is what I am going to use thank you.

Mar 8, 2010 at 1:10 PM

Hello,

Im just getting started with both XNA and Farseer. I'm also doing a Pong and I had the exact same problem but from your solution I'm faced with another one... how do you make the ball not collide with the rails? sorry I'm just beginning : )

Thanks.

Mar 8, 2010 at 1:20 PM

Nevermind, I still hadn't read about the Collision group funcionality.

Sorry for spamming and thanks : )