how to make smooth jumping with love physics

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Seth144k
Prole
Posts: 29
Joined: Wed Jan 19, 2022 8:45 pm

how to make smooth jumping with love physics

Post 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
Attachments
idk.love
(337.38 KiB) Downloaded 81 times
Ross
Party member
Posts: 100
Joined: Tue Mar 13, 2018 12:12 pm
Contact:

Re: how to make smooth jumping with love physics

Post 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.
Seth144k
Prole
Posts: 29
Joined: Wed Jan 19, 2022 8:45 pm

Re: how to make smooth jumping with love physics

Post by Seth144k »

i tried that and it still does the same thing...
Ross
Party member
Posts: 100
Joined: Tue Mar 13, 2018 12:12 pm
Contact:

Re: how to make smooth jumping with love physics

Post 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.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot] and 8 guests