You can start with the methods we discussed here:
http://newtondynamics.com/forum/viewtopic.php?f=9&t=9214JernejL wrote:- Calculate force and torque needed to move a body to proper place
...
- Override body velocity to correct one
You could do both at once. Knowing target velocity and position, a naive approach would be to use half target velocity, and half of the velocity that would move position to target in some time like 0.2 seconds.
Advanced approach would be to set up equations of motion from existing state to the future, and from target state to the past using some max correction acceleration. Then intersect both trajectories so positions and velocities are equal and look at the resulting acceleartion telling you about forces. Math is a bit involved, so i hope (and believe) some naive approach is good enough.
Goal would be to allow a difference between client and server, but to have a bound it does not get too large, and also the correction forces should be pretty unnoticed.
Additionally you would need to predict those target values from a timestamp from the most recent package and eventually smooth it a bit.
Of course you could use something like kinematic joint instead of forces and torques as well.
(It's not that easy to control physics, so don't expect perfect results quickly. Starting with something like a picking mechanic (gravity gun) would be better because you feel yourself how the lag is, how things start to oscillate etc.)
EDIT:
We may overthink this! If you sync just position, velocity must be in sync as well, right?
(I often implemented ways to control position and velocity, but i always end up working with just position
)
Also, all i say is about syncing things that are not very different.
If, however, somebody outside a house throws a stone at a wall corner, it may fly left on the server and right at the client. If the stone is an important game object and must be kept in sync, i have no idea how to do this nicely other than teleporting it while the player hopefully looks away.