Page 1 of 1

cpBodySetVelLimit with negative value

Posted: Thu Sep 22, 2011 4:16 pm
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.

Re: cpBodySetVelLimit with negative value

Posted: Thu Sep 22, 2011 5:45 pm
by slembcke
You need to write your own integration callback. See the planet demo for an example.

Re: cpBodySetVelLimit with negative value

Posted: Fri Sep 23, 2011 12:53 pm
by ddt
Great!.

Thanks for the prompt reply.