How to smoothly interpolate game object positions in a network game?
Greetings Everyone!
I am working on an online multiplayer pool style game.
In the game, the player whose turn is to strike sends 10 packets per second to the server which then broadcasts it to other players.
A packet contains position, velocity and the rotation angle of each ball.
Now when i use the information in these packets to move the balls, the movement looks laggy (all rigidbodies are set to kinematic).
I tried using Lerp, with velocity. It makes movement smooth, but the movement looks incorrect. For example, the cue ball just lerps to the final position ignoring the path in between, and is never seen hitting any balls.
Here's the code: transform.position = Vector3.Lerp (transform.position, serverBallPos, 0.1f) + serverBallVel * Time.deltaTime;
How do i smoothly interpolate through these positions, following the correct path?
I found this really great article where it says Hermite interpolation can be used for this purpose.
https://gafferongames.com/post/snapshot_interpolation/
How do I use this?
Thanks in advance!