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.
restrict the movement
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: restrict the movement
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.
If you are using Chipmunk 4.x, use cpJoint and cpSpaceAddJoint() instead.
Code: Select all
cpConstraint *joint = cpGrooveJointNew(staticBody, paddleBody, cpv(paddle_x, paddle_y_min), cpv(paddle_x, paddle_y_max), cpvzero)
cpSpaceAddConstraint(joint)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 2
- Joined: Wed Dec 02, 2009 11:18 am
- Contact:
Re: restrict the movement
thx,it is what i needed!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.If you are using Chipmunk 4.x, use cpJoint and cpSpaceAddJoint() instead.Code: Select all
cpConstraint *joint = cpGrooveJointNew(staticBody, paddleBody, cpv(paddle_x, paddle_y_min), cpv(paddle_x, paddle_y_max), cpvzero) cpSpaceAddConstraint(joint)
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.
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: restrict the movement
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/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Who is online
Users browsing this forum: No registered users and 9 guests