![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Urben |
Hello,
I am just about to start with GoDot. I have quite fleshed out ideas already and I wonder about one aspect: deterministic physics.
To make it short, I want to create a singleplayer 3d parkour game. Two features I want to include are this:
- Reverse, where you can trigger a backwards sequence to get back to any point you want.
- Replay files for high scores that you can “run”, like a ghost car you see in racing games.
I want to do this with making logs of inputs that the game uses to get you to the exact spot in the exact time. Now I wonder if I run into problems with rounding errors, like when 0.0001m difference causes one to fall of the roof instead of jumping from it.
I heard fixed-point numbers limit this problem but they seem to not be a thing in Godot.
Are there resources I can read on this matter?
Replay files for high scores that you can “run”, like a ghost car you see in racing games.
This may not fully answer your question, but saving and loading replays doesn’t require determinism per se. You can save the 3D transforms of all objects in the scene every frame and replay them over time (with interpolation if needed, for slow motion playback). This makes replay files much larger, but they won’t break if you update the game’s physics logic. You can still use compression to make replay files smaller
Calinou | 2019-08-19 19:55
That surely works too and I am sure this is a matter of taste, but I try to get the “elegant” solution done with determinism with your idea being a plan B. So thanks for the submission!
I played a lot of Worms Armageddon back in the days and I was and still am amazed how tiny and accurate the replay files are. It was a locked frame rate (both visual and physics) of 50fps. I know it is a whole different thing with 3d games that use metric systems instead of pixel measurements but I want to try to make something comparable work.
Urben | 2019-08-19 20:12
Calinou is correct, I would say this is the most elegant solution.
To be precise this is not a problem of determinism, most physics engine are deterministic, in the sense that there is no randomness in the calculus. However the problem is that in most cases the game are chaotic, in the sense that very small changes can produce a very different result.
So if you want to stick with your solution, you have to work to reduce chaos in your game. Example: rounding positions where force are applied or rounding the applied forces to avoid floating point imprecision.
BraindeadBZH | 2019-08-19 20:40
Thanks for the comment!
Yes I am aware of the chaotic aspects. What I hope for is to include all factors that generate the same chaos over and over again. Though I yet don’t see how chaos can come up in my ideas, as there is pretty much only the player’s movement in a static world.
Do rounding positions eliminate floating point imprecision or do they “just” reduce them?
Urben | 2019-08-19 20:51
Rounding should totally eliminate imprecision as it only affects the decimal part.
BraindeadBZH | 2019-08-19 20:58
Oh you meant rounding to no digits after the dot? I assumed to like three digits after it. Sounds like that would make me lose alot of precision.
Urben | 2019-08-19 21:05