I am creating a multiplayer drag racing game and have difficulties mixing extrapolation and interpolation. To save network bandwidth i am getting information from the opponent only on his button press, which is:
car->speed = newSpeed;
car->distanceReached = newDistance;
car->currentForce = newForce;
And i extrapolate the rest until the next update from opponent. On player update, extrapolation kicks in:
//Find new acceleration, frictionForce and mass being constants.
car->acceleration = (car->currentForce - car->frictionForce) / car->mass;
//Calculate new velocity.
car->speed += car->acceleration * dTime;
//Reduce force.
car->currentForce -= car->friction * dTime;
if(car->currentForce < 0)
car->currentForce = 0;
//Update distance reached
car->distanceReached += car->speed;
So we got update from opponent - car starts moving until force is equal 0. This seems to be working fine. What is not - when update is received in the middle of extrapolation, i am setting new position directly as seen before and car jumps to adjust to the "real" position. So the question is - how to incorporate interpolation in this situation for car not to jump and not to ruin already running extrapolation?
EDIT: I think i understand - to have constant timestep, because by sending it to opponent it will know how many frames i am behind as you suggested, but how to make it frame rate independant then?
– Marius Kurgonas Apr 24 '14 at 08:28