Page 1 of 1
Make a body to jump?
Posted: Thu Oct 09, 2008 9:12 am
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?
Re: Make a body to jump?
Posted: Thu Oct 09, 2008 11:25 am
by maximile
Try applying an impulse instead.
Re: Make a body to jump?
Posted: Thu Oct 09, 2008 12:04 pm
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.
Re: Make a body to jump?
Posted: Fri Oct 10, 2008 10:04 am
by sickman
Ok thanks.
Re: Make a body to jump?
Posted: Fri Mar 20, 2009 11:43 am
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)
Re: Make a body to jump?
Posted: Fri Mar 20, 2009 3:54 pm
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.