Apply force for period of time

Official forum for the Chipmunk2D Physics Library.
Post Reply
elfenleid
Posts: 1
Joined: Mon Feb 10, 2014 9:05 am
Contact:

Apply force for period of time

Post by elfenleid »

Hi,

I'm looking into applying a force to a flying object that opposes gravity. The thing is that I only want to apply the force for a brief period of time.

Any help appreciated.

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

Re: Apply force for period of time

Post by slembcke »

Nothing fancy about it, you just need to change the forces at the right times. In Chipmunk 6, a forces on a body persist until you reset them. So if you aren't using the force property for anything else you could set an upward force when you want to start floating, and then set it back to zero when you want it to stop.

Alternatively, you could make a velocity integration function that simply doesn't apply the gravity when a certain boolean flag in your code is set. Take a look at the planet demo for an example.
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 13 guests