I’ll use “localGameTime” for what is called “renderTime” in my code and “displayTime” in flaviens.
Normally you or the server doesn’t control other ships. So this situation isn’t realistic.
If another player controls his ship he sends that change to the server. The server then incorporates that change into following snapshots and sends them to you. After that you’ll be able to see the course correction.
The only way for everyone to hit “the gas” at the same time is when something happens ingame at a fixed time.
This isn’t different from other games. If you have ever tried coordinating in them.
That’s not what’s happening. Time itself slows down. This allows you to stay in formation with everything else when you lag out. In “Lomsor_15” I have added a display that shows the current speed of the localGameTime. 1 s/s is normal. As we all know.
First off let me say that I understand what you point to. Usually a game has a fixed cycle times for such things one can rely on. By slowing down time these cycles might run more often than they should in a certain localGameTime-frame.
But just bear with me please …
Justification
By letting the physics continue while you change localGameTime you break that exact relationship. If it is not slowed down the client and server desync.
The client is playing in the past. If lag increases he needs to play further in the past. So you change your localGameTime.
-
If you change it instantly everything is fine. All the remote ships are jumped back to older positions but your ship stays where it was. You now play further in the past.
-
If you change it over multiple cycles but let the local physics run, like you did in the original Interpolation test. The remote ships will be set back over a period of time. But you will have travelled forward in the meantime.
All other ships now are further in the past except for the players ship time, it didn’t change.
You have effectively run more physics cycles. If you compare their localGameTime timespamps they will be spaced at different intervals.
There you have a different outcome.
I don’t see why the distance to the other ship should change when my latency changes. And so won’t the server. The server will set the player back to where he should be. Without the player doing anything wrong.
- If you change the speed of localGameTime clock like I suggest as option 2 further down, physics still runs in a fixed step relative to the localGameTime clock!
For instance. 100 physics ticks per localGame Second. If you slow down or speed up the rate at which localGameTime change (speed of time) these ticks will still be spaced exactly the same if you compare their localGameTime timespamp.
Interpolating time is effectively making the timesmooth have the same effect as an instant change of localGameTime
Solution
-
Make localGameTime changes instant
Screw all this interpolation stuff. Take my “setTargetTime” code.
Do this:renderTime = targetTime;
SetlatencySampleAmmounthigh.
Usual lag and jitter should run quite stable. Some “snaps” when first adjusting.
Drawback
Quite unusual lag spikes will result in two “snaps”. Gamers are used to such stuff. -
Make physics etc. run at a different rate when localGameSpeed is different
For instance instead of usingphysicsAcc += elapsedyou could:
localGameElapsed = localGameTime- localGameTimeLast;
physicsAcc += localGameElapsed
orphysicsAcc += elapsed*localGameSpeed(localGameSpeed in seconds per second)
Render Interpolation should make it still look smooth.
Drawback
Update rate might increase too much while speeding up time. Client Hardware might choke.
(Speed change can be adjusted/capped though. See my code for an example of a cap.)
(1000ms of lag increase would mean only 10% higher update rate at a total interpolation time of one second, though. Most people probably wouldn’t even notice this one second.)
The way I currently have it on the client won’t work, yes. But so won’t the original client physics code.
Anyway …
These should not result in a desync. I thought about it quite extensively.
Input should also work the same way you have planed. With Solution one being exactly the same and solution two just everything being slowed down/sped up for a short amount of time.
I hope you may consider option two. With option one you may need to add some restriction when and how often it is run. Option two can run all the time as small changes aren’t even noticed as they are smoothed out near instantly.
Anyway. Hope this work can be useful.
For something that might happen maybe a few times a match we sure invested a lot of time into it.
Also. You mentioned how the client physics code should be the same as the server physics code. No matter what I try I can’t get the physics code form the server to run at a consistent rate on the client. I always get some form of stutter. (I removed smoothTime)
Would be nice to know why that is.


TIME TRAVEL IS WEEIIIIRDDDD
The auto-formation function at the moment I find a little… tricky!