Dear Löve users,
I'm facing a bug i've not been able to fix for a few days.
My game is a platformer, I use HC for collisions.
Here is the problem:
When my game lags too much (the first time I launch it on a linux session, or on windows when I launch two instances of the game), my objects with gravity go throug the ground!
The bug seams not due to HC, because I tried to debut by adding a print(self.y) in my character class, and when the bug appears, the first value to be printed is huge like 1900, instead of 300 when the bug does not appears.
I also tried to put JIT off, but it did not fix.
You can browse the code here https://github.com/Kivutar/twinsisters
I also attach my love file.
Thanks.
Gravity and lag
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Gravity and lag
Tunneling it's a bad, bad thing. When the framerate is too low, your player falls under the ground in 1 frame, so the normal collision detection can't stop it... I remember there's a way to prevent it (setting the object as 'bullet' or something like that), but I don't remember if it's on HC or love.physics...
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Gravity and lag
Thanks for your reply.
What do you mean by tunneling? Sorry, my english is bad.
Is the bullet trick the body type "kinematic" in Box2D: https://love2d.org/wiki/BodyType ? Because I searched HC reference for such a thing and found nothing.
There must be a way to avoid that. I suppose there is a lot of platformers made with HC. What is the right way to handle it? I read a lot of code from the forum and my gravity system seamed to be the most common way to implement a platformer engine.
Also, many forum members advice to not use love.phisics for simple platformers, and HC is said to be the best collision lib for high speed bodies.
What do you mean by tunneling? Sorry, my english is bad.
Is the bullet trick the body type "kinematic" in Box2D: https://love2d.org/wiki/BodyType ? Because I searched HC reference for such a thing and found nothing.
There must be a way to avoid that. I suppose there is a lot of platformers made with HC. What is the right way to handle it? I read a lot of code from the forum and my gravity system seamed to be the most common way to implement a platformer engine.
Also, many forum members advice to not use love.phisics for simple platformers, and HC is said to be the best collision lib for high speed bodies.
Re: Gravity and lag
I explained what tunneling is:
When the framerate is too low, your player falls under the ground in 1 frame, so the normal collision detection can't stop it
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: Gravity and lag
This problem really isn't Hard-On Collider exclusive. I actually had this problem a long time ago, and even though I wasn't using HC, the solution still applies. Read thoroughly: viewtopic.php?f=4&t=8740
I LÖVE, therefore I am.
Re: Gravity and lag
Thanks a lot. Now I understand where this bug comes from. I applied this fix in my main.lua update(dt)
And any idea why my game lag so much on windows? It runs at 40 FPS wih windows, and 60 FPS on Linux, same laptop (macbook).
Code: Select all
dt = math.min(dt, 0.07)
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: Gravity and lag
Interesting... I myself am on windows, and I decided to check to see how much lag there really was, and it doesn't even open. All other .loves do open, though. Something weird is going on with this thing...
I LÖVE, therefore I am.
Re: Gravity and lag
Well I use OSX and game opens (no player visible). Since my recent platform testing experience I noticed that in same machine dt OS time behaves different at loading/first moments. OSX and XP works ok for me. Win7/Win8 acts in another way. That leads that something dropping/airborne at start is not caught right away and ends outside screen.Puzzlem00n wrote:Interesting... I myself am on windows, and I decided to check to see how much lag there really was, and it doesn't even open. All other .loves do open, though. Something weird is going on with this thing...
Kivutar, I feel I'm having a kind of problem like you with this viewtopic.php?f=4&t=10042. First attachment there don't "work" with W7/W8 and I had to fix start position the "player" in ground at start (instead of funny drop).
Re: Gravity and lag
Yes I think our bugs have the same cause.
Maybe having a title screen will be a natural workaround to this bug.
Here is the fixed .love file. Puzzlem00n can you test it please? It lauches well on my win7.
Maybe having a title screen will be a natural workaround to this bug.
Here is the fixed .love file. Puzzlem00n can you test it please? It lauches well on my win7.
Re: Gravity and lag
It launches well (and player is show dropping) in snow leopard too. I'm happy that you had same idea of parachute playerKivutar wrote:Yes I think our bugs have the same cause.
Maybe having a title screen will be a natural workaround to this bug.
Here is the fixed .love file. Puzzlem00n can you test it please? It lauches well on my win7.
But I add that I tested an older version taken from your git and already was working well before. Only the new .love taken from this thread had the "hidden" (beneath the ground?) player
Who is online
Users browsing this forum: No registered users and 2 guests