Page 1 of 1

how to make smooth jumping with love physics

Posted: Tue Aug 09, 2022 11:41 pm
by Seth144k
so im trying to make a prototype of a platformer and i got some things to work accept the jumping... the jumping sort of works but its really jerky and essentially just teleports you up. I want to make it so that its smooth but i just dont know how. I am using a library called windfield which is just a wrapper for love.physics. can anyone please help me! i provided my .love file

Re: how to make smooth jumping with love physics

Posted: Wed Aug 10, 2022 12:52 am
by Ross
The problem is, you are setting your player's Y velocity to zero every frame. So when you try to jump, you apply the upward impulse and it moves upward for one frame, but then you set the Y velocity to zero, so it stops moving up. Then it floats downward because the physics engine still applies a bit of gravity to it each frame before you set the Y velocity to zero again.

Just let the physics engine control the Y velocity and you'll be all set.

Code: Select all

local _, currentVY = self.collider:getLinearVelocity()
self.collider:setLinearVelocity(px, currentVY)
After that you'll find that your jump impulse is way too high. Around -5000 is more reasonable.

Re: how to make smooth jumping with love physics

Posted: Wed Aug 10, 2022 6:31 pm
by Seth144k
i tried that and it still does the same thing...

Re: how to make smooth jumping with love physics

Posted: Wed Aug 10, 2022 10:24 pm
by Ross
Are you using git? Check to see what else you changed.

If I download your 'idk.love' file, extract it, and copy-paste those two lines above to replace line 53 of src/kyle.lua, then it works.