A major issue I am encountering right now is that my physics engine (BEPU) and my network interpolation are conflicting with each other.
The player is a physics object, and so the physics engine updates it every update on the client. When the client receives an authoritative position from the server, it replays the player's commands since the position was sent, and sets a "serverPos" variable in the player controller to that value.
Unfortunately, if a player should be on the other side of a bump in the terrain, the interpolation code will move the player into the terrain, which will cause loop of the player getting pushed back, the interpolation algorithm trying to push the player back in, and so forth until the engine literally explodes and gives me an NaN error.
My interpolation algorithm is extremely simple; each update, I keep track of how far the player has moved, add that to the interpolation target, and subtract away the distance interpolated from the last frame:
serverPos += Position - lastPosition - interpolationDistance; // interpolated distance should not be factored into the target, as it will cause an infinite chain
Vector3 preInterp = Position;
Position = Vector3.Smoothstep(Position, serverPos, 0.3f);
interpolationDistance = Position - preInterp;
Any advice on how to deal with this is greatly appreciated.