Nifty Gui and rootNode/bulletAppState problems

In my game, i just created a menu where I can select multiplayer and go into the lobby. Code below…
[java]package mygame;

import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.animation.AnimEventListener;
import com.jme3.animation.Bone;
import com.jme3.animation.LoopMode;
import com.jme3.animation.SkeletonControl;
import com.jme3.app.SimpleApplication;
import com.jme3.audio.AudioNode;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.collision.CollisionResults;
import com.jme3.font.BitmapFont;
import com.jme3.font.BitmapText;
import com.jme3.font.Rectangle;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Ray;
import com.jme3.math.Vector3f;
import com.jme3.network.*;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.renderer.queue.RenderQueue;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.scene.control.BillboardControl;
import com.jme3.shadow.DirectionalLightShadowRenderer;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.NiftyEventSubscriber;
import de.lessvoid.nifty.builder.ElementBuilder;
import de.lessvoid.nifty.builder.TextBuilder;
import de.lessvoid.nifty.controls.Chat;
import de.lessvoid.nifty.controls.ChatTextSendEvent;
import de.lessvoid.nifty.controls.ListBox;
import de.lessvoid.nifty.controls.ListBoxSelectionChangedEvent;
import de.lessvoid.nifty.controls.chatcontrol.ChatControl;
import de.lessvoid.nifty.controls.dynamic.TextCreator;
import de.lessvoid.nifty.controls.listbox.ListBoxControl;
import de.lessvoid.nifty.controls.listbox.ListBoxView;
import de.lessvoid.nifty.controls.textfield.TextFieldControl;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.elements.render.TextRenderer;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;
import java.awt.Component;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import mygame.UtNetworking.AddPlayerMessage;
import mygame.UtNetworking.ChatMessage;
import mygame.UtNetworking.HitPlayerMessage;
import mygame.UtNetworking.LocationMessage;
import mygame.UtNetworking.StartGameMessage;
import mygame.UtNetworking.UpdatePlayerHit;
import mygame.UtNetworking.UpdatePlayersMessage;
import mygame.UtNetworking.UserDataMessage;

public class ClientMain extends SimpleApplication implements ActionListener, AnimEventListener, ScreenController {

private Client client;
private ConcurrentLinkedQueue<String> messageQueue;
Spatial scene;
private boolean up = false, left = false, down = false, right = false, crouch = false;
private float walkspeed = .22f;
public static String Username;
Map clientPlayers = new HashMap();
Map clientAnimChannels = new HashMap();
Map clientSkeletonControls = new HashMap();
Map clientPlayerTags = new HashMap();
CharacterControl player;
//BetterCharacterControl betterPlayer = new BetterCharacterControl(2f, 6, 10);
BulletAppState bulletAppState = new BulletAppState();
boolean shoot = false;
AudioNode gunshot;
AudioNode hitMarker;
LocationMessage loc = new UtNetworking.LocationMessage();
Vector3f currentLoc = new Vector3f();
Vector3f oldLoc = new Vector3f();
boolean moving = false;
Vector3f walkDirection = new Vector3f();
PlayerData thisPlayer;
private Nifty nifty;
private NiftyJmeDisplay niftyDisplay;
private TextRenderer statusText;
HashMap playerNodes = new HashMap();
AnimChannel channel;
AnimControl a;
BitmapText ch;
BitmapFont GuiFont;

public static void main(String... args) throws Exception {

    // Username = getString(null, "UserName", "Enter Username:", "_username_");
    // if (Username == null) {
    //     System.out.println("User cancelled.");
    //     return;
    //  }
    //  System.out.println("UserName: " + Username);

    UtNetworking.initialiseSerializables();

    ClientMain app = new ClientMain();
    app.start();
    app.setDisplayStatView(false);
    app.setPauseOnLostFocus(false);


}

public static String getString(Component owner, String title, String message, String initialValue) {
    return (String) JOptionPane.showInputDialog(owner, message, title, JOptionPane.PLAIN_MESSAGE,
            null, null, initialValue);
}

public ClientMain() {
    super();
}

private void startNifty() {
    flyCam.setEnabled(false);
    inputManager.setCursorVisible(true);
    guiNode.detachAllChildren();
    guiNode.attachChild(fpsText);
    niftyDisplay = new NiftyJmeDisplay(assetManager,
            inputManager,
            audioRenderer,
            guiViewPort);
    nifty = niftyDisplay.getNifty();
    try {
        nifty.fromXml("Interface/ClientUI.xml", "Menu", this);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    statusText = nifty.getScreen("load_game").findElementByName("layer").findElementByName("panel").findElementByName("status_text").getRenderer(TextRenderer.class);
    guiViewPort.addProcessor(niftyDisplay);
}

/**
 * updates the list of players in the lobby gui, threadsafe
 */
public void updatePlayerData(Map players) {
    Logger.getLogger(ClientMain.class.getName()).log(Level.INFO, "Updating player data");

    Screen screen = nifty.getScreen("lobby");
    ListBox listBox = screen.findNiftyControl("players_list", ListBox.class);

    Iterator it = players.keySet().iterator();
    listBox.clear();
    while (it.hasNext()) {
        String name = (String) it.next();
        System.out.println("Adding " + name + " To lobby");
        listBox.addItem(name);

    }

}

public void connect() {
    //System.out.println("Clicked connect");
    //TODO: not connect when already trying..
    final String userName = nifty.getScreen("load_game").findElementByName("layer").findElementByName("panel").findElementByName("username_text").getControl(TextFieldControl.class).getText();
    if (userName.trim()
            .length() == 0) {
        setStatusText("Username invalid");
        return;
    }
    Username = userName;

    statusText.setText(
            "Connecting..");
    try {
        client = Network.connectToServer("192.168.1.20", UtNetworking.Port);
        client.addMessageListener(new NetworkMessageListener(), UserDataMessage.class);
        client.addMessageListener(new NetworkMessageListener(), AddPlayerMessage.class);
        client.addMessageListener(new NetworkMessageListener(), LocationMessage.class);
        client.addMessageListener(new NetworkMessageListener(), HitPlayerMessage.class);
        client.addMessageListener(new NetworkMessageListener(), UpdatePlayerHit.class);
        client.addMessageListener(new NetworkMessageListener(), UpdatePlayersMessage.class);
        client.addMessageListener(new NetworkMessageListener(), StartGameMessage.class);
        client.addMessageListener(new NetworkMessageListener(), ChatMessage.class);
        client.start();
        messageQueue = new ConcurrentLinkedQueue<String>();

    } catch (IOException ex) {
        setStatusText(ex.getMessage());
        Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
    }
    //lobby();
    thisPlayer = new PlayerData(userName, "Models/BFSoldier11.j3o");

    client.send(new UserDataMessage(thisPlayer));
    Element chatPanel = nifty.getCurrentScreen().findElementByName("layer").findElementByName("bottom_panel").findElementByName("chat_panel");
    Chat chatCon = chatPanel.findNiftyControl("chatId", Chat.class);

    chatCon.addPlayer(Username, null);
}

/**
 * sets the status text of the main login view, threadsafe
 *
 * @param text
 */
public void setStatusText(final String text) {
    enqueue(new Callable<Void>() {
        public Void call() throws Exception {
            statusText.setText(text);
            return null;
        }
    });
}

public void addChat(final String text) {
    enqueue(new Callable<Void>() {
        public Void call() throws Exception {
            Screen screen = nifty.getScreen("lobby");
            Element chatPanel = nifty.getCurrentScreen().findElementByName("layer").findElementByName("bottom_panel");
            Chat chatCon = chatPanel.findNiftyControl("chat", Chat.class);
            chatCon.receivedChatLine(text,
                    null);
            System.out.println(chatCon.getPlayers());



            return null;
        }
    });
}

@NiftyEventSubscriber(id = "chat")
public void onChatTextSendEvent(final String id, final ChatTextSendEvent event) {
    // You should post that text to the server ... 
    System.out.println("Recieved text ");
    sendMessage(event.getText());
    // here we simply post it to the chat window
    // chat.receivedChatLine(event.getText(), chatIconNiftyUser);

    // and we generate a random reaction from the void player =)
    //chat.receivedChatLine(getRandomResponse(), chatIconVoid);
}

@NiftyEventSubscriber(id = "listBox")
public void onListBoxSelectionChanged(final String id, final ListBoxSelectionChangedEvent<String> event) {
    // List<String> selection = event.getSelection();
    //for (String selectedItem : selection) {
    //   System.out.println("listbox selection [" + selectedItem + "]");
    //}
}

//FIXME: nifty cannot find sendChat() when sendChat(String text) is existing too
public void sendMessage(String text) {
    client.send(new ChatMessage(text, Username));
}

public void lobby() {
    inputManager.setCursorVisible(true);
    nifty.gotoScreen("lobby");
}

public void Multiplayer() {
    nifty.gotoScreen("load_game");
}

public void startGame() {
    //TODO: map selection
    client.send(new StartGameMessage(Username));
}

@Override
public void simpleInitApp() {
    startNifty();
    gunshot = new AudioNode(assetManager, "Sounds/M16sound.wav");
    hitMarker = new AudioNode(assetManager, "Sounds/HitMark.wav");
    gunshot.setPositional(false);
    hitMarker.setPositional(false);
    stateManager.attach(bulletAppState);
    // try {
    //client = Network.connectToServer("192.168.1.20", UtNetworking.Port);
    // client.addMessageListener(new NetworkMessageListener(), UserDataMessage.class);
    // client.addMessageListener(new NetworkMessageListener(), AddPlayerMessage.class);
    // client.addMessageListener(new NetworkMessageListener(), LocationMessage.class);
    // client.addMessageListener(new NetworkMessageListener(), HitPlayerMessage.class);
    //  client.addMessageListener(new NetworkMessageListener(), UpdatePlayerHit.class);
    //  client.addMessageListener(new NetworkMessageListener(), UpdatePlayersMessage.class);
    // client.start();
    // } catch (IOException ex) {
    //     Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
    //  }

    //UserDataMessage udm = new UserDataMessage(Username, "Models/Soldier.j3o");
    //client.send(udm);
    //System.out.println("Joined game");
    setUpKeys();
    //cam.setLocation(new Vector3f(30, 20, 30));
    //cam.lookAt(new Vector3f(0, 5, 0), Vector3f.UNIT_Y);
    //flyCam.setEnabled(false);
    //inputManager.setCursorVisible(true);

    // scene = assetManager.loadModel("Scenes/Ground.j3o");
    // CollisionShape mapcs = CollisionShapeFactory.createDynamicMeshShape(scene);
    // RigidBodyControl maprig = new RigidBodyControl(mapcs, 0);
    // bulletAppState.getPhysicsSpace().add(maprig);
    // rootNode.attachChild(scene);


    // client.addMessageListener(new NetworkMessageListener());

    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun);
    /* this shadow needs a directional light */
    DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, 1024, 2);
    dlsr.setLight(sun);
    viewPort.addProcessor(dlsr);

    AmbientLight ambient = new AmbientLight();
    ambient.setColor(ColorRGBA.White);
    rootNode.addLight(ambient);

    //CapsuleCollisionShape cs = new CapsuleCollisionShape(2, 6);
    //player = new CharacterControl(cs, 1.5f);
    //bulletAppState.getPhysicsSpace().add(player);
    //player.setJumpSpeed(20);
    //player.setPhysicsLocation(new Vector3f(0, 5, 0));

    //thisPlayer = new PlayerData(Username, "Models/BFSoldier11.j3o");
    //client.send(new UtNetworking.UserDataMessage(thisPlayer));


}
Vector3f realloc = new Vector3f();
String chatText;

@Override
public void simpleUpdate(float tpf) {

    //if (thisPlayer.dirty) {
    //client.send(new UtNetworking.UpdatePlayersMessage(thisPlayer));
    //System.out.println("sending updateplayermessage for "+thisPlayer.getUsername());
    //thisPlayer.dirty = false;
    //}
    movement(tpf);
}

private void movement(float tpf) {
    if (player != null) {
        Vector3f camDir = cam.getDirection().clone().multLocal(walkspeed);
        Vector3f camLeft = cam.getLeft().clone().multLocal(walkspeed - .05F);
        walkDirection.set(0, 0, 0);

        if (left) {
            walkDirection.addLocal(camLeft);
            moving = true;
        }
        if (right) {
            walkDirection.addLocal(camLeft.negate());
            moving = true;
        }
        if (up) {
            if (player.onGround()) {
                //if (!"Walk.001".equals(thisPlayer.getAnimation())) {
                thisPlayer.setAnimation("Walk.001");
            }
            //}

            walkDirection.addLocal(camDir.getX(), 0, camDir.getZ());
            moving = true;
        }
        System.out.println("is on ground?" + player.onGround());

        if (down) {
            walkDirection.addLocal(camDir.negate().getX(), 0, camDir.negate().getZ());
            moving = true;
        }
        if (!player.onGround()) {
            //realloc = new Vector3f(player.getPhysicsLocation().x, player.getPhysicsLocation().y-5, player.getPhysicsLocation().z);
            thisPlayer.setLocation(new Vector3f(player.getPhysicsLocation().x, player.getPhysicsLocation().y - 5, player.getPhysicsLocation().z));

        }
        thisPlayer.setDirection(new Vector3f(cam.getDirection().x * 180, cam.getDirection().y, cam.getDirection().getZ() * 180));

        // if (thisPlayer.dirty) {
        client.send(new UtNetworking.UpdatePlayersMessage(thisPlayer));
        //   thisPlayer.dirty = false;
        //}
        player.setWalkDirection(walkDirection);

        //client.send(new UtNetworking.UpdatePlayersMessage(thisPlayer));
        if (moving) { //if player moved
            thisPlayer.setLocation(new Vector3f(player.getPhysicsLocation().x, player.getPhysicsLocation().y - 5, player.getPhysicsLocation().z));

            //client.send(new UtNetworking.UpdatePlayersMessage(thisPlayer));
            moving = false;
        }
        if (moving == false) {
            if (!crouch) {
                if (player.onGround()) {
                    thisPlayer.setAnimation("Idle");
                }
            }
        }
        if (player != null) {
            cam.setLocation(new Vector3f(player.getPhysicsLocation().x,
                    player.getPhysicsLocation().y + 6,
                    player.getPhysicsLocation().z));
        }
        if (shoot) {
            shoot();
            //client.send(new ShootMessage(cam.getLocation(), cam.getDirection(), 1.0f, Username));
            shoot = false;
        }

        //System.out.println(thisPlayer.getAnimation());
    }

}




public void bind(Nifty nifty, Screen screen) {
    //ListBox listBox = screen.findNiftyControl("players_list", ListBox.class);
    //listBox.addItem(Username);
}

public void onStartScreen() {
}

public void onEndScreen() {
}

private class NetworkMessageListener implements MessageListener<Client> {

    public void messageReceived(Client source, Message m) {
        if (m instanceof ChatMessage) {

            final ChatMessage msg = (ChatMessage) m;
            System.out.println("Recieving Message from: " + msg.getUsername());
            System.out.println(msg.getUsername() + ": " + msg.getText());
            addChat(msg.getUsername() + ": " + msg.getText());
        }

        if (m instanceof AddPlayerMessage) {

            final AddPlayerMessage addPlayerMessage = (AddPlayerMessage) m;
            final PlayerData pd = addPlayerMessage.getPlayerData();

            ClientMain.this.enqueue(new Callable() {
                public Object call() throws Exception {

                    Iterator it = addPlayerMessage.getAllPlayers().keySet().iterator();  // loop thru server players
                    while (it.hasNext()) {
                        String name = (String) it.next();  // server player name
                        PlayerData p = (PlayerData) addPlayerMessage.getAllPlayers().get(name); //gets server player
                        if (!thisPlayer.getUsername().equalsIgnoreCase(name) && clientPlayers.get(name) == null) {   // look up server name in client map
                            //clientPlayers.put(addPlayerMessage.getUsername(), addPlayerMessage.getPlayerData());
                            //updatePlayerData();
                            // addPlayer(p);  // if not found, add it.
                            // System.out.println("I am: " + thisPlayer.getUsername() + " Loading from server: " + name);
                        } else {
                            //fpsText.setText(Username + " Joined the game");
                        }
                    }
                    lobby();
                    if (addPlayerMessage.getUsername() != Username) {
                        clientPlayers.put(addPlayerMessage.getUsername(), addPlayerMessage.getPlayerData());
                    }
                    //System.out.println("Recieved update player data message");
                    updatePlayerData(addPlayerMessage.getAllPlayers());

// if (pd.getUsername().equalsIgnoreCase(thisPlayer.getUsername())) { //if this player
// fpsText.setText(Username + " Joined the game");
// //System.out.println(“Joined”);
// }
// if (players.size() < addPlayerMessage.getAllPlayers().size()) { //there is a player this client doesnt know about
// //for (Map player : addPlayerMessage.getAllPlayers()) {
// // if (!names.equals(Username)) {
// Node g = (Node) players.get(names);
// if (g == null) {
// addPlayer(names, addPlayerMessage.getFilename());
// System.out.println(Username + " is loading player " + names);
// }
// }
// }
//}
return null;
}
});

        }
       
        if (m instanceof StartGameMessage) {

            final StartGameMessage message = (StartGameMessage) m;
            
            if (message.getUsername().equals(Username)) {
                nifty.removeScreen(nifty.getCurrentScreen().getScreenId());
                loadMap(message.getmapName());
                loadMe();
                loadAllClients();
                inputManager.setCursorVisible(false);
                flyCam.setEnabled(true);
                //nifty.gotoScreen("default_hud");
                
            }


        }
        if (m instanceof UpdatePlayersMessage) {

            final UpdatePlayersMessage message = (UpdatePlayersMessage) m;

//System.out.println("Received broadcase from server re: " + message.getPlayerData().getUsername());

            ClientMain.this.enqueue(new Callable() {
                public Object call() throws Exception {
                    String currentAnim = message.getPlayerData().getAnimation();
                    //PlayerData playerData = message.getPlayerData();
                    //System.out.println("Updating clientPlayers with new data from "+ message.getPlayerData().getUsername());
                    Node tag = (Node) clientPlayerTags.get(message.getPlayerData().getUsername());
                    if (tag != null) {
                        //ch.lookAt(cam.getLocation(), Vector3f.UNIT_Y);
                        tag.setLocalTranslation(message.getPlayerData().getLocation().x, message.getPlayerData().getLocation().y + 15, message.getPlayerData().getLocation().z);
                    }

                    clientPlayers.put(message.getPlayerData().getUsername(), message.getPlayerData());
                    Node pnode = (Node) playerNodes.get(message.getPlayerData().getUsername());
                    if (pnode != null) {
                        // System.out.println("update node for "+playerData.getUsername());
                        pnode.setLocalTranslation(message.getPlayerData().getLocation());
                        pnode.lookAt(new Vector3f(message.getPlayerData().getDirection().x, 0, message.getPlayerData().getDirection().z), Vector3f.UNIT_Y);   //     setDirection(playerData.getDirection())

                    }

                    SkeletonControl playerBones = (SkeletonControl) clientSkeletonControls.get(message.getPlayerData().getUsername());
                    if (playerBones != null) {
                        Bone head = playerBones.getSkeleton().getBone("head");
                        Bone leftShoulder = playerBones.getSkeleton().getBone("upper_arm.L");
                        Bone rightShoulder = playerBones.getSkeleton().getBone("upper_arm.R");
                        head.setUserControl(true);
                        rightShoulder.setUserControl(true);
                        leftShoulder.setUserControl(true);
                        System.out.println("Head y rot = " + message.getPlayerData().getDirection().y);
                        Quaternion q = new Quaternion();
                        Quaternion p = new Quaternion();
                        //Quaternion l = new Quaternion();
                        float angle = message.getPlayerData().getDirection().y;
                        q.fromAngles(-angle, 0, 0);
                        //p.fromAngles(angle, 0, 0);
                        p.fromAngles(0, 0, -angle);
                        // l.fromAngles(angle * 1.2f, 0, 0);
                        head.setUserTransforms(Vector3f.ZERO, q, Vector3f.UNIT_XYZ);
                        leftShoulder.setUserTransforms(Vector3f.ZERO, p, Vector3f.UNIT_XYZ);
                        rightShoulder.setUserTransforms(Vector3f.ZERO, p, Vector3f.UNIT_XYZ);
                    }




                    AnimChannel playerAnim = (AnimChannel) clientAnimChannels.get(message.getPlayerData().getUsername());

                    if (playerAnim != null) {
                        String oldAnim = playerAnim.getAnimationName(); //The player data's anim name
                        System.out.println(message.getPlayerData().getUsername() + " i playing " + currentAnim + " animation");
                        if (!currentAnim.equals(oldAnim)) {

                            if ("Jump".equals(currentAnim)) {
                                playerAnim.setAnim(currentAnim, .2f);
                                playerAnim.setSpeed(1);
                                playerAnim.setLoopMode(LoopMode.DontLoop);
                            }
                            if ("Walk.001".equals(currentAnim)) {
                                playerAnim.setAnim(currentAnim, .2f);
                                playerAnim.setSpeed(1.5f);
                                playerAnim.setLoopMode(LoopMode.Loop);
                            }
                            if ("Crouching".equals(currentAnim)) {
                                playerAnim.setAnim(currentAnim, .2f);
                                playerAnim.setSpeed(1);
                                playerAnim.setLoopMode(LoopMode.DontLoop);
                            }
                            if ("Idle".equals(currentAnim)) {
                                if ("Jump".equals(oldAnim)) {
                                    playerAnim.setAnim(currentAnim, .1f);
                                } else {
                                    playerAnim.setAnim(currentAnim, .2f);
                                }

                                playerAnim.setSpeed(1);
                                playerAnim.setLoopMode(LoopMode.DontLoop);
                            }

                        }

                    }


                    return null;


                }
            });
        }
    }
}

public void loadMap(String file) {
    scene = assetManager.loadModel(file);
    CollisionShape mapcs = CollisionShapeFactory.createDynamicMeshShape(scene);
    RigidBodyControl maprig = new RigidBodyControl(mapcs, 0);
    bulletAppState.getPhysicsSpace().add(maprig);
    rootNode.attachChild(scene);
    System.out.println("Map loaded");
}


public void loadMe() {
    CapsuleCollisionShape cs = new CapsuleCollisionShape(2, 6);
    player = new CharacterControl(cs, 1.5f);
    bulletAppState.getPhysicsSpace().add(player);
    player.setJumpSpeed(20);
    player.setPhysicsLocation(new Vector3f(0, 5, 0));
    System.out.println("Me loaded");
}

public void PlayerDie(Node p) {
}


}

public void RemovePlayer(String Username) {
}

@Override
public void destroy() {
    if (client != null) {
        client.close();
    }

// client.send(new UtNetworking.RemovePlayerMessage(Username));
}

private void setUpKeys() {
    inputManager.addMapping("Left", new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping("Right", new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping("Up", new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping("Down", new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping("Jump", new KeyTrigger(KeyInput.KEY_SPACE));
    inputManager.addMapping("Pause", new KeyTrigger(KeyInput.KEY_P));
    inputManager.addMapping("Crouch", new KeyTrigger(KeyInput.KEY_LCONTROL));
    inputManager.addMapping("Shoot", new MouseButtonTrigger(mouseInput.BUTTON_LEFT));

    inputManager.addListener(this, "Left");
    inputManager.addListener(this, "Right");
    inputManager.addListener(this, "Up");
    inputManager.addListener(this, "Down");
    inputManager.addListener(this, "Jump");
    inputManager.addListener(this, "Pause");
    inputManager.addListener(this, "Shoot");
    inputManager.addListener(this, "Crouch");

}

public void onAction(String binding, boolean value, float tpf) {
    if (player != null) {
        if (binding.equals("Left")) {
            left = value;
        } else if (binding.equals("Right")) {
            right = value;
        } else if (binding.equals("Up")) {
            up = value;
        } else if (binding.equals("Down")) {
            down = value;
        } else if (binding.equals("Jump")) {
            if (!value) {

                player.jump();
                thisPlayer.setAnimation("Jump");

            }
        } else if (binding.equals("Pause")) {
            if (!value) {
                flyCam.setEnabled(!flyCam.isEnabled());
                inputManager.setCursorVisible(!inputManager.isCursorVisible());
            }
        } else if (binding.equals("Shoot") &amp;&amp; !value) {
            shoot = true;
        } else if (binding.equals("Crouch")) {
            if (player.onGround()) {
                thisPlayer.setAnimation("Crouching");
            }
            crouch = value;
        }
    }
}

}[/java]
After the game starts, I can see the map but immediatly, i get the error: at com.bulletphysics.collision.broadphase.DbvtBroadphase.setAabb(DbvtBroadphase.java:203)
at com.bulletphysics.collision.dispatch.CollisionWorld.updateSingleAabb(CollisionWorld.java:222)
at com.bulletphysics.collision.dispatch.CollisionWorld.updateAabbs(CollisionWorld.java:247)
at com.bulletphysics.collision.dispatch.CollisionWorld.performDiscreteCollisionDetection(CollisionWorld.java:135)
at com.bulletphysics.dynamics.DiscreteDynamicsWorld.internalSingleStepSimulation(DiscreteDynamicsWorld.java:378)
at com.bulletphysics.dynamics.DiscreteDynamicsWorld.stepSimulation(DiscreteDynamicsWorld.java:339)
at com.jme3.bullet.PhysicsSpace.update(PhysicsSpace.java:330)
at com.jme3.bullet.PhysicsSpace.update(PhysicsSpace.java:317)
at com.jme3.bullet.BulletAppState.render(BulletAppState.java:257)
at com.jme3.app.state.AppStateManager.render(AppStateManager.java:300)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:251)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)
And the app crashes. Is there a thread or something I need to close in the GUI first?

I also got
Problem spatial name: Root Node
at com.jme3.scene.Spatial.checkCulling(Spatial.java:260)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:647)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:640)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:974)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1029)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:744)

Sometimes I tell people that the stack trace is the most important part… but I guess the name of the exception is important also.

To quote from the Spatial.checkCulling() exception:

Scene graph is not properly updated for rendering.
State was changed after rootNode.updateGeometricState() call.
Make sure you do not modify the scene from another thread!

Perhaps your networking thread modified the scene?

@sgold said: To quote from the Spatial.checkCulling() exception:

Scene graph is not properly updated for rendering.
State was changed after rootNode.updateGeometricState() call.
Make sure you do not modify the scene from another thread!

Perhaps your networking thread modified the scene?


The only thing that modifies the scene is the one client .

@pspeed said: Sometimes I tell people that the stack trace is the most important part... but I guess the name of the exception is important also.
The root node problem doesn't happen all the time but the physics one does and I have need seen it before and in not doing anything different than I have in the past. I don't even know what the error is. What usually causes that problem?
@Jmonkier said: The root node problem doesn't happen all the time but the physics one does and I have need seen it before and in not doing anything different than I have in the past. I don't even know what the error is. What usually causes that problem?

I don’t know either. You could help by providing the details of the exception (as @pspeed suggested) so we don’t have to guess.

The only thing that modifies the scene is the one client .

Well that narrows down the problem a bit. The error must be caused by that client!

What do you mean by “the client”?

If you have networking then networking messages are handled on a separate thread. Since networking messages are handled on a separate thread then they CANNOT modify the scene graph directly.

@pspeed said: What do you mean by "the client"?

If you have networking then networking messages are handled on a separate thread. Since networking messages are handled on a separate thread then they CANNOT modify the scene graph directly.


Thanks guys, I figured it out this morning. This was the only message I forgot to put client.queue Callable() and Call() on so it works now. :wink: