Make a body to jump?

Official forum for the Chipmunk2D Physics Library.
Post Reply
sickman
Posts: 19
Joined: Mon Oct 06, 2008 7:50 am
Contact:

Make a body to jump?

Post by sickman »

I want to make a body to jump, but apply_force makes it act weird (it never slows down).

Is there a "proper way" to make the body jump? Or did I do the force applying wrong?
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Make a body to jump?

Post by maximile »

Try applying an impulse instead.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Make a body to jump?

Post by slembcke »

Forces act continuously until you reset them. Impulses modify the object's velocity immediately. Impulses are a much better way to implement things like jumping or guns firing.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
sickman
Posts: 19
Joined: Mon Oct 06, 2008 7:50 am
Contact:

Re: Make a body to jump?

Post by sickman »

Ok thanks.
3mode
Posts: 1
Joined: Thu Oct 09, 2008 9:48 am
Contact:

Re: Make a body to jump?

Post by 3mode »

ok evrything is fine but what is r (some offset or what) and j (some vector of what ?) ?

Code: Select all

cpBodyApplyImpulse(cpBody *body, cpVect j, cpVect r)
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Make a body to jump?

Post by slembcke »

Yeah, it's the shorthand used in all the physics equations. Someday I'll refactor all the naming to make it more clear. I swear :(

j is the impulse expressed as a vector in absolute coordinates. r is the offset from the center of gravity of the body, also expressed in absolute coordinates.
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: Bing [Bot] and 12 guests