I'm developing a game like Slither.io but I have planned to add weapons and another additional stuff, I implemented the Gabriel Gambetta example which runs perfectly only if the character is updated (position modified) by inputs, but in my case, I'm updating the character in the main loop of Server with a Constant velocity and if in the client side is prediction activated the character is updated too, in the client side the issue is the constant jittering when I do Prediction, Server reconciliation, and the Entity Interpolation .

I've Read several articles which talks about this, but all of them are games where characters can stop its position then move. But in my game always is moving.

Here is a video about the game issue (On left side is the Client view, the green circle is the server position)

The apply input and update of a player are:

void applyInput(InputData input)
     Direction = input.direction;
     Angle = Math.Atan2(Direction.y, Direction.x);
     Angle *= 180 / Math.PI;

void Update(float deltatime)
    // Rotate around a center
    Vector2 Dir = Utils.Rotate(this.Center, this.Foward, this.fHeadRotation);
    this.fRotationDifference  = this.fHeadRotation - this.Angle;
    if (fRotationDifference < 0 && fRotationDifference > -180 || fRotationDifference > 180)
        fHeadRotation += Utils.ANGULAR_VELOCITY * deltatime;
    else if (fRotationDifference > 0 && fRotationDifference < 180 || fRotationDifference < -180)
       fHeadRotation -= Utils.ANGULAR_VELOCITY * deltatime;

    Dir = Dir .mulRef(deltatime); 
    Dir = Dir .mulRef(Utils.NORMAL_SPEED);

    //Here the position is modified, same formula for server and client
    position.x += Dir.x;
    position.y += Dir.y;

Then comes my questions:

  1. The Gabriel Gambetta's formula doesn't work for this game, then which formula/algorithm/concept can be applied here for prediction and server reconciliation (it will appreciate pseudocode for illustrating).
  2. Due to real-time multiplayer game, the position of other players must be almost precise, then I ask which formula can be applied, I mean Interpolation or extrapolation, in my tries of doing interpolation always the character stays in position behind of the received from server, currently I'm using a lerp function to update position of other players, then which method and . which formula/algorithm/concept can be used.
  3. Maybe can be used the article How to compensate for moving objects with client side prediction? 4.Are the model of applyInput() and Update() right, or can be changed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.