cpBodySetVelLimit with negative value

Official forum for the Chipmunk2D Physics Library.
Post Reply
ddt
Posts: 2
Joined: Tue Sep 20, 2011 1:44 pm
Contact:

cpBodySetVelLimit with negative value

Post by ddt »

Hello,

I am simulating an object going up and down. I want to limit the upward velocity to a certain negative value, for instance:
cpBodySetVelLimit(_ballBody, -60.0);

But as far as I can see the speed is limited also for downward direction because when the object goes down it reaches a limit velocity of:
+60.0

Furthermore, once the object reaches the limit velocity (either -60 when going upwards or +60 when going downwards) it begins to bounce between -60 and +60.

QUESTION:
How can I limit the velocity of the object but only in a particular direction?

Thanks in advance.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpBodySetVelLimit with negative value

Post by slembcke »

You need to write your own integration callback. See the planet demo for an example.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
ddt
Posts: 2
Joined: Tue Sep 20, 2011 1:44 pm
Contact:

Re: cpBodySetVelLimit with negative value

Post by ddt »

Great!.

Thanks for the prompt reply.
Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests