Page 1 of 1

restrict the movement

Posted: Wed Dec 02, 2009 11:34 am
by Miktor
Hi,I make a game of ping pong.
It is necessary to limit the position of the racket along the axis y.
But if I create a racket of infinite mass and infinite momentum that the racket can not be moved with the aid of power only through a direct change of x, then the racket will have zero speed, but for me it is unacceptable, what to do?
Sry for my bad English.

Re: restrict the movement

Posted: Wed Dec 02, 2009 1:33 pm
by slembcke
It sounds like you want to attach a groove joint between a static body and your paddles. Use INFINITY for the moment of inertia so it can't rotate, but use a normal mass.

Code: Select all

cpConstraint *joint = cpGrooveJointNew(staticBody, paddleBody, cpv(paddle_x, paddle_y_min), cpv(paddle_x, paddle_y_max), cpvzero)
cpSpaceAddConstraint(joint)
If you are using Chipmunk 4.x, use cpJoint and cpSpaceAddJoint() instead.

Re: restrict the movement

Posted: Thu Dec 03, 2009 12:30 pm
by Miktor
slembcke wrote:It sounds like you want to attach a groove joint between a static body and your paddles. Use INFINITY for the moment of inertia so it can't rotate, but use a normal mass.

Code: Select all

cpConstraint *joint = cpGrooveJointNew(staticBody, paddleBody, cpv(paddle_x, paddle_y_min), cpv(paddle_x, paddle_y_max), cpvzero)
cpSpaceAddConstraint(joint)
If you are using Chipmunk 4.x, use cpJoint and cpSpaceAddJoint() instead.
thx,it is what i needed!
Is there any way to eliminate the influence of the body to another?
That is, I need that one body to change their behavior after the collision, and others not.
Is it possible at the moment of impact to the body to exert force on the opposite applied to it, how to calculate this force.

Re: restrict the movement

Posted: Thu Dec 03, 2009 12:33 pm
by slembcke
Not really, though by making one body really heavy and the other very light you'll get much of the same effect.