Stephane Hockenhull

Mar 24, 2021 19:26
sorry I gotta go now, nice chat.
Mar 24, 2021 19:26
yeah the tweaking changes, but now it'll be more stable with different timestamps.

This math applies to variable-delta-time particle systems too so it's a good habit.
Mar 24, 2021 19:24
yeah
Mar 24, 2021 19:23
" Integrals 'n' stuff "
Mar 24, 2021 19:23
Because friction is a "surface under the curve" type of math.
Mar 24, 2021 19:22
You probably should, just in case you decide to increase the fixedupdate because computers can't cope later down the project, so you don't have to re-tweak all your values.
Mar 24, 2021 19:19
Like if you have a real-time farming simulation game, you'll want a "catching up ..." overlay.
If it's an action game I'd just treat it as a pause.
Mar 24, 2021 19:18
Either you limit the catch-up updates, or display a "catching up..." overlay
Mar 24, 2021 19:17
yeah.
Mar 24, 2021 19:16
LOL
Mar 24, 2021 19:15
How long you could play depended on how fast your computer was. The slower the computer (the bigger the delta time) the more you could play before it rounded down to nothing.
Mar 24, 2021 19:15
Morrowind had that bug where after around 80 hours of play, fast computers had too small of a deltatime and animations stopped working due to rounding down updates to nothing.
Mar 24, 2021 19:14
yeah, that's the numerically stable way to go about it.

That way even if the computer somehow runs at 10000 fps your physics won't break when trying to add too-small of a fraction that gets rounded down to zero.
Mar 24, 2021 19:11
this.remainingTime -= physicsTimestep;
Mar 24, 2021 19:10
You update bool variables with the button states. And your update() looks at those booleans.
Mar 24, 2021 19:08
The browser process those between animate calls., so they're kind of "once per frame"
Mar 24, 2021 19:06
including inputs.
Mar 24, 2021 19:06
yeah, anything that affect outcomes need to be on the fixed update.
It's just less of a headache that way.
Mar 24, 2021 19:01
yes
Mar 24, 2021 19:01
Like smoke particles don't affect outcome.
or calculating the length of trails when drawing them
Mar 24, 2021 19:00
right. As long as your other systems don't affect the outcome you're good.
Mar 24, 2021 18:59
and so on...
Mar 24, 2021 18:59
+10ms: physics(4) physics(4) physics(4), particles(12), draw(12), processed_total=12
+10ms: physics(4) physics(4) particles(8), draw(8), processed_total=20
Mar 24, 2021 18:57
ack, that last line was supposed to be physics(4) physics(4) physics(4), then physics(4)physics(4)
Mar 24, 2021 18:55
You can also do physics(4) physics(4) so for a total of 12ms (went over but it's okay), and next time if you get another 10ms (total of 20ms) you then go physics(4) physics(4)
Mar 24, 2021 18:54
Only ever call whole timesteps.
Mar 24, 2021 18:53
If you have 10ms you call physics(4) physics(4) so for a total of 8ms, and next time if you get another 10ms (total of 20ms) you go physics(4) physics(4) physics(4).
Mar 24, 2021 18:50
I cannot recommend a specific frame rate as this depends on physics complexity and your minimum system requirements, Javascript engine performance, etc. You'll have to try it out for yourself as you develop your game. But I will recommend using a delta time variable parameter to the physics update function so you can change the fixed time-step. So long as it's consistent between computers you'll avoid a lot of [bug that only happen on fast or slow systems] situations.
Mar 24, 2021 18:50
@DMGregory I was just adding that :) In general for numerical stability I prefer to calculate physics at a fixed rate. @Ryan Say you decide to run your simulation at 100Hz (10ms) and you have a 1.003 second delta, you end up running your update physics loop 100 times. In pseudo-code: new_time = now(); while(sim_time < new_time) { Update(10ms); sim_time += 10ms; }
 

 Game Development

Game development and other polite discussion. Game development...
Dec 14, 2018 16:28
Already got mine :D
Sep 24, 2018 20:07
#JustElderScrollsThings
Sep 24, 2018 19:04
@DMGregory Are you editing your answer? I'm going to revert my changes if you're not mid-edit.
Sep 24, 2018 18:35
I think the table is off by one. when you reach 16 777 216 you can't add 1 anymore, gotta add 2... or am I confused again?
Sep 24, 2018 18:34
waaaaait...
`16 777 216 - 33 554 432 2^0 = 1`
Sep 24, 2018 18:34
I usually just do my physics in fixed points. Only doing the square root in float after subtracting in fixed points.
Sep 24, 2018 18:23
Like, if I made a 2D game with at least 8bit of pixel fractions (like old 8bit/16bit games used in their physics) I could walk 65536 pixels either directions before I don't have those 1/256th of a pixel anymore.
Sep 24, 2018 18:20
Because usually the [ smallest unit value of concern ] scale is what matters the most in practical terms. Even though in practice it gets a lot worse due to other rounding.
Sep 24, 2018 18:18
I'm used to think of it in equivalent fixed-points precision for a given distance unit rather than a given exponent.
Sep 24, 2018 18:17
Now that I re-read it, your numbers were right.
Sep 24, 2018 18:15
ooooh okay. put that way yes
Sep 24, 2018 18:12
Or rather, it's +/- 2^-25 error
Sep 24, 2018 18:11
I think it's 2^-24 error
Sep 24, 2018 18:11
I'm trying to figure out if it's 2^-24 error or 2^-25 error...
Sep 24, 2018 18:10
darn float implicit bit is confusing
Sep 24, 2018 18:10
you were one too low in your answer...
Sep 24, 2018 18:09
I was one too high here in the chat :P
Sep 24, 2018 18:09
Not 2^23 numbers
Sep 24, 2018 18:09
So it's ` we have 2^24 representable numbers, spaced 2n−24 apart.`
Sep 24, 2018 18:08
that's why it's 24bits of precision
Sep 24, 2018 18:08
no, you're right. 2^23 stored you can still add 1