Game Development Reference
In-Depth Information
How it works...
To simulate an environment with problems such as packet loss, we changed the FPS on the
server to 10. Instead of sending out the 30 updates per second it did before, it will only
send one every tenth of a second. This is not the same as 100 ms of latency, since it says
nothing about the turnaround time. It's more as if two out of three updates were lost on the
way, a 66 percent packet loss.
Previously, the client simply took the values it got from the server and applied them to the
local players. Using interpolation, the player's position and rotation will move towards the
latest actual position and rotation in steps every update.
We implemented the interpolation by first determining the interpolation factor. This was
done by dividing tpf by the amount of time (roughly, in seconds) we would like the inter-
polation to take. The actual time will be longer since the steps become shorter with each
update.
We then input this value and use the interpolation method of Vector3f and the slerp
method of Quaternion to move them towards the actual values.
This is done by using a factor based on the tpf value provided in the update method. By
doing so, the interpolation time will be roughly the same regardless of the frame rate. We
should be aware that this in reality becomes latency, a delay between the action and appear-
ance, as we have added a slight delay to when the player reaches the actual position.
Search WWH ::




Custom Search