Update and DeltaTime vary too much, is there a way to have deterministic gameplay by recording user input and feeding it back into the game (assuming no randomness elsewhere)
I’m writing an app that records user input sent to the game and then allows for a replay feature by resending the input as it was received. This is resulting in inaccurate playback where the player loses in the reply before where they actually lost.
Any advice on how I can achieve this? Below is a simple example of my use-case that isn’t working.
INITAL GAME
[GAME STARTS] TimeElapsed = 0
[UPDATE 1] Update(dt), dt = 0.05, -> TimeElapsed += dt
[USER CLICKS] RecordInput at TimeElapsed, or 0.05
[UPDATE 2] Update(dt), dt = 0.043, -> TimeElapsed += dt
[GAM ENDS]
GAME REPLAY
[APP LOADS INPUT DATA] Known input = at dt 0.05, action = Click
[GAME STARTS] TimeElapsed = 0
[UPDATE 1] Update(dt), dt = 0.045, -> TimeElapsed += dt
[UPDATE 2] Update(dt), dt = 0.057, -> TimeElapsed += dt -> [ALERT APP]
[APP CHECKS INPUT DATA], finds input at 0.05, -> [APP CLICKS]
[ERROR] RecordInput, at TimeElapsed, so 0.057, was supposed to occur at 0.05
[REPLAY FAILS]
A real example (these are the incremented delta time values (TimeElapsed) sent to my app by Update):
FRAME PLAYING = 9.402000000000006
FRAME PLAYING = 9.702000000000005
FRAME PLAYING = 10.002000000000004
FRAME PLAYING = 10.219000000000003
[User had clicked at: 10.619] but this wasn’t called because the next time update was called was: FRAME PLAYING = 10.783999999999983
Notice how each call to update varies wildly (update could be called between 2-10 times per second). That’s the difference between life and death in my game so input needs to be exact.
Is there any better way to achieve my goals with exact precision?
Thanks