Page 2 of 2

Re: Platformer Prototype

Posted: Sat May 14, 2011 4:34 pm
by DrLuke
that's dt for you :)

Re: Platformer Prototype

Posted: Sat May 14, 2011 5:15 pm
by DrLuke
I added a fixed timestep now. Aka you can't fall through the floor when moving the window anymore.

http://dl.dropbox.com/u/28079852/PlatformerProto14.love

Re: Platformer Prototype

Posted: Sat May 14, 2011 8:17 pm
by BlackBulletIV
I wouldn't use a fixed timestep, it's better to limit how much delta time Box2D gets access to:

Code: Select all

local left = dt
local step = .03

while left > 0 do
  world:update(step)
  left = left - step
end
Another way to fix this problem (by my observations) would be to use Body:setBullet. Set that to true, and Box2D will check for collision in a "real-time" way.

Re: Platformer Prototype

Posted: Sat May 14, 2011 10:10 pm
by Lafolie
I'm curious, does this microstep/window movement phenomena only apply to box2D-style physics? I plan on making a platformer one day and I was wondering if I'd have to take this into account using pseudo physics.

Re: Platformer Prototype

Posted: Sat May 14, 2011 10:14 pm
by bartbes
It depends on your calculations, but most calculations do, in fact, need small timesteps for them to at least look like they're accurate.

So, in general:
The smaller the timestep, the more accurate the result. (in most cases, if you recalculate from the start, this is not the case)

Now, as for why this is, these formulas have been created and verified with dt approaching 0, if that means anything to you.

Re: Platformer Prototype

Posted: Sat May 14, 2011 10:47 pm
by DrLuke
I am not using box2d. I made everything myself!

Re: Platformer Prototype

Posted: Sun May 15, 2011 12:38 am
by BlackBulletIV
The problem would come from the fact that calculations are done using the delta time. For example:

Code: Select all

body.x = body.x + body.vx * dt
The longer the delta time, the more that it added to the position of the object. Unless setBullet is set to true, Box2D will just move the object by whatever body.vx * dt happens to be without checking whether anything was in between.
DrLuke wrote:I am not using box2d. I made everything myself!
Ah ok, but the same thing still applies. When doing your physical updates, limit the delta time as I showed above.

EDIT: 777 posts! :awesome:

Re: Platformer Prototype

Posted: Sun May 15, 2011 5:09 pm
by bmzz
when the player stand on ground and i hit right(or left) gently, player will Jitter.

Re: Platformer Prototype

Posted: Tue May 17, 2011 7:36 am
by DrLuke
bmzz wrote:when the player stand on ground and i hit right(or left) gently, player will Jitter.
Yeah, that's a problem with the friction, soon to be solved.

Re: Platformer Prototype

Posted: Sun May 29, 2011 12:18 am
by DrLuke
Fasten your seatbelts and don't let any limbs hang outside of the table's boundaries, I'm presenting you:
Collisions with triangles!

ncSoY.png
ncSoY.png (30.43 KiB) Viewed 462 times

http://dl.dropbox.com/u/28079852/Collisions16.love