Network Interpolation Issues
Posted: Fri Feb 15, 2013 5:28 am
Hi, Norbo!
I've ran into a somewhat game-breaking issue after testing my game with 100ms ping. As my server is completely authoritative over position, the client corrects its position to the server's position. Instead of snapping the player to the position, I have a "server_pos" variable, which stores the server's position + replayed movement, and the player interpolates its position towards the "server_pos" variable. The problem is, when I threw in some random network spikes, the interpolation could move the player into the terrain, which would cause the physics engine to try to push the player out, which would offset the interpolation, which would then try to do a harsher correction, etc. until the physics engine reports an NaN value for velocity.
This is essentially what I am doing:
https://dl.dropbox.com/u/59540455/net_i ... on_bug.mp4
As you told me before that you had some experience with physics networking, do you have any advice on how to deal with this? Would there be any serious repercussions
if the pushing players out of terrain is disabled?
Thanks!
I've ran into a somewhat game-breaking issue after testing my game with 100ms ping. As my server is completely authoritative over position, the client corrects its position to the server's position. Instead of snapping the player to the position, I have a "server_pos" variable, which stores the server's position + replayed movement, and the player interpolates its position towards the "server_pos" variable. The problem is, when I threw in some random network spikes, the interpolation could move the player into the terrain, which would cause the physics engine to try to push the player out, which would offset the interpolation, which would then try to do a harsher correction, etc. until the physics engine reports an NaN value for velocity.
This is essentially what I am doing:
Code: Select all
Vector3 serverPos;
Vector3 interpolationDistance;
void interpolate()
{
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;
}
As you told me before that you had some experience with physics networking, do you have any advice on how to deal with this? Would there be any serious repercussions
if the pushing players out of terrain is disabled?
Thanks!