BulletAppState and AbstractAppState

Hey guys,
I am a noob in the JME3 engine.
I implemented a Player.class which extends the AbstractAppState.class and a Scene.class which extends also the AbstractAppState.class. This works fine.
My problem is the understanding of the so called BulletAppState.
To attach the physic in those classes, I have to call:
" bulletAppState.getPhysicsSpace().add(characterControl);" for example.
Now my question:
How i initialize the bulletAppState object?
Do I have to create a new instance: “BulletAppState bulletAppState = new …” in every AbstractAppState or do I use:
“bulletAppState = this.app.getStateManager().getState(BulletAppState.class);” ?

This is the correct way to go, unless your game is a really odd super huge thing or you require multiple physics environments, just create one BulletAppState and then add your physics objects to that one.

All right. Thank you!
Then I have another question. :smile:

I implemented an Enemy.class, which is not a AbstractAppState. The constructor is like that:

 public Enemy(Node _rootNode, AssetManager _assetManager, BulletAppState _bulletAppState, String _modelfile, String _modelMaterialFile, float radius, float height, float mass){
        rootNode = _rootNode;
        assetManager = _assetManager;
        model = assetManager.loadModel(_modelfile);
        material = assetManager.loadMaterial(_modelMaterialFile);
        model.setMaterial(material);
       // characterControl = new BetterCharacterControl(radius, height, mass);
        rigid = new RigidBodyControl(10);
        model.addControl(rigid);
       _bulletAppState.getPhysicsSpace().add(rigid);
     
        rootNode.addControl(rigid);
        rootNode.attachChild(model);         
    }

If I initialize an object of this class in the simpleInitApp(), and I attach the rigidBodyControl, the scene falls down. Its like that the scene overwrites its RigidBodyControl(0) with the RigidBodyControl(10). What is wrong here? Should i implement the Enemy as an AbstractAppState aswell?

Well, you added the control the root node. Why did you do that? That removed it from your object and made your whole scene a physics object.

You are awesome. :yum:
I have another question. :smile:

I have an AbstractAppState “FirstPersonCamera” and an AbstractAppState “ThirdPersonCamera”.
In the FirstPersonCamera you can shoot, run and walk. In the ThirdPersonCamera you can just run and walk. The cameras can be toggled with the left and right click of the mouse. I implemented the movements in both camera classes and the console says:
“Warnung: Attempted to add mapping “Run” twice to trigger.”,
for example.