restrict the movement

Official forum for the Chipmunk2D Physics Library.
Post Reply
Miktor
Posts: 2
Joined: Wed Dec 02, 2009 11:18 am
Contact:

restrict the movement

Post 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.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: restrict the movement

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Miktor
Posts: 2
Joined: Wed Dec 02, 2009 11:18 am
Contact:

Re: restrict the movement

Post 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.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: restrict the movement

Post by slembcke »

Not really, though by making one body really heavy and the other very light you'll get much of the same effect.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests