Physics bounce bug

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.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Physics bounce bug

Post by vrld »

It's a bug in your game.
Engine wise:
bartbes wrote:There is nothing we can do!
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Physics bounce bug

Post by Boolsheet »

Now I'm curious. How is time advancing a bug or faulty behavior?

Besides capping dt, it's also possible to update it in small steps.

Code: Select all

local limit = 0.1

function love.update(dt)
    while dt > 0 do
        updateFuncs(math.min(dt, limit))
        dt = dt - limit
    end
end
Checking and limiting dt is always a good idea.
Shallow indentations.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Physics bounce bug

Post by Taehl »

Jasoco wrote:(Which for a 60FPS game should be something between .004 and .02 seconds give or take.)
[...]
For a 60FPS game, it's probably safe to cap it at 0.029 using math.min(0.029, dt).
I would advise not capping it that low, because then any time the game dips under the full 60 FPS, the game will essentially start running in slow-motion. People with systems less powerful than the developer's will always see the game in slow-motion! It's better to cap it at something higher than that.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Physics bounce bug

Post by tentus »

vrld wrote:It's a bug in your game.
Engine wise:
bartbes wrote:There is nothing we can do!
I'm being unclear, I'm sorry. I do not expect anyone to do anything, the onus of dealing with this clearly falls on the Lover, not the Love staff.

That said, if we define a bug as a defect in software, then this is still a bug, even if there is nothing to be done. Love will (unexpectedly) apply an upwards force when players do an action that was not expected, which happens to be setup-dependent. Since we can't anticipate this behavior in the player, it falls to the Lover to compensate for this behavior, even though the weirdness is coming from Love. That's fine, but I'd still say its a bug in Love.

We should cast this as a feature!
Kurosuke needs beta testers
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Physics bounce bug

Post by Taehl »

Technically, the objects aren't just being shoved upward. What's happening is that the physics thinks that all the objects are moving down extremely fast (due to the cumulative force of gravity over a long period of time), and thus has to make them bounce off of the floors really hard.

I'm pretty sure that's how it works, at least.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Physics bounce bug

Post by Jasoco »

Taehl wrote:
Jasoco wrote:(Which for a 60FPS game should be something between .004 and .02 seconds give or take.)
[...]
For a 60FPS game, it's probably safe to cap it at 0.029 using math.min(0.029, dt).
I would advise not capping it that low, because then any time the game dips under the full 60 FPS, the game will essentially start running in slow-motion. People with systems less powerful than the developer's will always see the game in slow-motion! It's better to cap it at something higher than that.
You know, you're right. What would you suggest capping it at?

Maybe you could use an if statement to detect if dt is greater than say .5 (Half a second) and then if so, just cap it to .025. It won't matter since the dt is never supposed to go that high anyway and the only time it would is when you drag the window. So it would be safe that way.

Make sure the if/then is before anything else code-wise. I'd actually just put it in love.run right after dt = love.timer.getDelta(). And then just make sure to never place any game timing relying code directly on getTime(), instead use what I suggested by just adding to a variable called gameTime.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Physics bounce bug

Post by Taehl »

I, personally, like capping dt to 0.04 (dt = math.min(dt, 0.04)). That's a nice, simple number, and it works out to an even 25 FPS - if the framerate is lower than that, then things will start moving in slow-motion. However, I consider that just fine since 25 FPS is where things start to get choppy, and the slowdown is actually helpful.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Physics bounce bug

Post by Jasoco »

Taehl wrote:I, personally, like capping dt to 0.04 (dt = math.min(dt, 0.04)). That's a nice, simple number, and it works out to an even 25 FPS - if the framerate is lower than that, then things will start moving in slow-motion. However, I consider that just fine since 25 FPS is where things start to get choppy, and the slowdown is actually helpful.
Yeah, good idea. I mean, even the NES had slowdown back in the day when too many enemies were on screen, and Löve is way faster than an NES.
User avatar
miko
Party member
Posts: 410
Joined: Fri Nov 26, 2010 2:25 pm
Location: PL

Re: Physics bounce bug

Post by miko »

bartbes wrote:It is no bug!
There is nothing we can do!
Is it based on real time clock? If so, hibernating/suspending the OS (like when closing the laptop's lid) would also trigger this "bug" (or "undefined behaviour", I would say). Also, what happens if you change the system time (changing date/hour)?
So, it seems, it is risky to depend on system time.
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest