how to make smooth jumping with love physics
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
how to make smooth jumping with love physics
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
- Attachments
-
- idk.love
- (337.38 KiB) Downloaded 81 times
Re: how to make smooth jumping with love physics
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.
After that you'll find that your jump impulse is way too high. Around -5000 is more reasonable.
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)
Re: how to make smooth jumping with love physics
i tried that and it still does the same thing...
Re: how to make smooth jumping with love physics
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.
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.
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot] and 8 guests