Synchronization in multiplayer

I make multiplayer game.
Algorithm:

  1. i press key on key board.
  2. character control move setup animations.
  3. result pack to json and send to server.
  4. server resend result to all computers
  5. install result to “bot” model.
  6. update.

In character class i have two methods:

update() - method which update local model.
updateBot(); method which update bot model in other models.

public void updateBot() {
        //проверка были ли анимация изменена
        //добавить скорость
        
        rotateChannel.setAnim(rotateAnimation);
        rotateChannel.setLoopMode(LoopMode.DontLoop);

        runChannel.setAnim(runAnimation);
        runChannel.setLoopMode(LoopMode.DontLoop);

        
        if (Jump) {

            if(characterControl.onGround()){
                characterControl.jump();
            }
        }
        

        /**
          * Move and rotate model
          */
         walkDirection.set(0, 0, 0);
         
         if (Left) {
             walkDirection.addLocal(camLeft.mult(speed));
         }
         if (Right) {
             walkDirection.addLocal(camLeft.mult(speed).negate());
         }
         if (Up) {
             walkDirection.addLocal(camDir.mult(speed));
             //rotate_channel.setLoopMode(LoopMode.DontLoop);
         }
         if (Down) {
             walkDirection.addLocal(camDir.mult(speed).negate());
         }

         characterControl.setWalkDirection(walkDirection.mult(speed));
        
         float[] angles = new float[3];
         camRotation.toAngles(angles); // we get the cam angles here
         angles[0] = 1.75f; // you don't want to rotate along the x-axis, so we set it to 0
         angles[2] = 0; // you don't want to rotate along the z-axis, so we set it to 0


         moveSpatial.setLocalRotation(moveSpatial.getLocalRotation().fromAngles(angles));
    }

Question:
if i use Left Right Up Down - user key press.
it works but asynchronously (It would be more correct to use the time of pressing or setting the exact coordinates)

How to make more accurate synchronization

  • precise positioning.

Questions:
1. What send to server (characterControl parameters)?
2. How to install parameters to bot?

1 Like

Key press send to server. Only server move character. Server send pos of character to all computer. look at sim-eth examples.

1 Like

He isn’t using Zay-ES, is he?

1 Like

I have coordinates:

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

Jul 23, 2017 10:49:59 PM com.jme3.animation.SkeletonControl controlRender
INFO: Hardware skinning engaged for base.obj (Node)

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714
update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715
update player_id: 22 camLeft -0.15078059 1.14738945E-7 0.13139714

update player_id: 22 camDir -0.19635175 -0.02604162 -0.22531715

1 Like

no clue what you mean. look at sim-eth examples. it is done right there. your way is wrong. dont send keys you press to all computer.

2 Likes

Give link to examples.
Don’t understand what is “sim-eth examples”?

1 Like
2 Likes

I don’t know what he is doing. not at all. He talks in a telegram style. it is anyway impossible to help him. maybe examples can help him :confused:

3 Likes

Мне тяжело разговаривать по английски :slight_smile:

I speak briefly so that it is clear

1 Like

Not contains source codes…

1 Like

I don’t need server client server examples.

I already write client-servers path.

Questions:

  1. What send to server (characterControl parameters)?
  2. How to install parameters to bot?
1 Like

Questions:

  1. What send to server (characterControl parameters)?
  2. How to install parameters to bot?
1 Like

Sorry, but I think you are kidding us!

We actually should flag every topic you create. Sorry, but obviously I am not the only one who thinks that…

2 Likes

No!.

I mean:
Use setPhysicsLocation - exact method.
Use move with Spatial class - exact method.
Use wap - exact method.

This will work exactly and synchronously.

If i use human key press, have problems with: internet speed,computers speed, operating system (low level libraries),etc…

1 Like

Fuck me, I’m out!

2 Likes

yep me too

1 Like

You could do this even slower if you wrote it to a zip file, gzipped that, then sent that, ungzipped it, unzipped it, read it… then rezipped and gzipped for the return trip. Heheh. Or maybe print it out and scan it.

Note: if your plan is to make a real time game then you are already on the wrong path because your networking is going to be waaaaaaaaaay too slow for the internet. This is why folks keep trying to point you to better examples because your approach will never work for a real time game.

Good luck, anyway.

5 Likes

Thanks.
What approach do you propose to use?
I need to forward arrays and variables.
What will work faster?

To use p2p between players?

1 Like

I can:

  1. Create command by region by ping: players from one city or republic. with ping between clients 20-30ms.
  2. Send packet between players - server only connector.

Question: how to send data faster and more efficient than packing in json.

1 Like

You could make a board game?

2 Likes