I have a server-reliant multiplayer Unity3D game, where the server is written in Node.js. The server sends updates to the positions of players, and the players lerp to those positions on the client to simulate smooth movement. I am not using Unity physics for player movement. I get around 20 packet updates per second, so I use the time between each update divided by the 0.12 seconds lerp interval.
The code I use to calculate the deltaTime for the lerping of player movement is:
lerpValue = Mathf.Clamp01((DateTime.UtcNow.Millisecond - lastPacket.UpdateTime) / 120;
myTransform.position = Vector3.Lerp (myTransform.position, lastPacket.Pos, lerpValue);
This seems to smooth out the movement of the players, but I cannot get the camera to consistently and smoothly follow the player. I use Time.deltaTime in LateUpdate for the camera smoothing. This makes it choppy, jerky, and stutter. I would also like the camera lerping a little bit behind the player, so if the player movement stutters the camera does not.
I have tried turning VSync on and off, moving player movement to FixedUpdate, and moving the camera from LateUpdate to FixedUpdate, and am looking for any more suggestions.