Change animation in cycle

  1. I have two players.
  2. First player local, second player listen key press from server (multiplayer) and install to model.
  3. keys install to player.
  4. players update in cycle.

Local player animations work.
Bot (multiplayer model with keys from server) animations not work.

All players update in one loop:

  for(String key : players.keySet()){
                
                //System.out.println("player: " + key);
                //players.get
                
                updatePlayer(players.get(key),tpf);
               //players.get(key).tpfUpdate(); 
              
            }

public void updatePlayer(final Player player, final float tpf) {
        enqueue(new Callable<Void>() {
            public Void call() throws Exception {
                
                
                player.update(tpf);
               
                
                return null;
            }
        });
    }

Update method then player press right:

   if (Right) {
            if (!isDirectRight) {
                isDirectRight = true;

                isLeftDirect = false;
                isDirectLeft = false;
                isRightDirect = false;

                System.out.println("player_id: " + id + " right_press direct-half-right");

                rotateChannel.setAnim("direct-half-right");
                rotateChannel.setLoopMode(LoopMode.DontLoop);
            }
        }

But animation change only on local player.

1 Like

The absence of logic is an insoluble problem.

4 Likes

Logic:

  1. i press key
  2. key insert in model
  3. model calculate logic
  4. game level update model
  1. Learn English
  2. Read about basic 3D stuff
  3. Learn jME by reading the wiki
  4. Write something simple in jME to test what you have learned
  5. repeat step 3 + 4 continuously
7 Likes

Work this:

@Override
  public void simpleUpdate(float tpf) {
        for(String key : players.keySet()){

                
               updatePlayer(players.get(key),tpf);
              
        }
 }

 public void updatePlayer(final Player player, final float tpf) {
        enqueue(new Callable<Void>() {
            public Void call() throws Exception {
                
                 //logic....
                return null;
            }
        });
 }