Bulletappstate question


I have a small test case, to experiment with physics.

I create floor (box mesh) and make it solid in the simpleInitApp()
I also added some logic, that when i click the mouse button, a sphere is shot in the direction of the camera.

This is all working fine, the sphere is bouncing on the floor etc.

But then I tried to move the floor creation to a separate appstate, but now the sphere is going through the floor.
Can someone explain me what I am doing wrong?

public class Particles extends SimpleApplication {

public static void main(String[] args) {
    Particles particles = new Particles();

public void simpleInitApp() {

    // Let there be light
    DirectionalLight sun = new DirectionalLight();
    AmbientLight ambientLight = new AmbientLight();


    // Add user mappings
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");

    stateManager.attach(new FloorState());

private ActionListener actionListener = new ActionListener() {
    public void onAction(String s, boolean b, float v) {
        if (s.equals("shoot") && !b) {

private void shootFireball() {
    // Fireball
    Spatial fireball = assetManager.loadModel("textures/fireball/fireball.obj");


    fireball.addControl(new FireballControl(cam.getDirection()));


public class FloorState extends AbstractAppState {
private BulletAppState bulletAppState;
private RigidBodyControl solidPhysics;

public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);

    // Create a physical game
    bulletAppState = new BulletAppState();

    // Create a solid control with a mass of zero
    solidPhysics = new RigidBodyControl(0f);

    // Mesh
    Box boxMesh = new Box(Vector3f.ZERO, 1, 1, 1);

    // Floor material
    Material floorMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    floorMaterial.setColor("Color", ColorRGBA.Blue);

    // Wall material
    Material wallMaterial = floorMaterial.clone();
    wallMaterial.setColor("Color", ColorRGBA.Green);

    // Container for solid models
    Node solidNodes = new Node("solid");

    // Floor spatial
    Geometry floor = new Geometry("floor", boxMesh);
    floor.setLocalScale(25f, 0f, 25f);

    // Wall spatial
    Geometry wall = new Geometry("wall", boxMesh);
    wall.setLocalScale(5f, 0f, 5f);
    // Rotate 90°
    Quaternion rotate90 = new Quaternion();
    rotate90.fromAngleAxis(90 * FastMath.DEG_TO_RAD, Vector3f.UNIT_X);
    wall.setLocalTranslation(0f, 5f, 0f);

    // Add models to the container

    // Make the container solid

    // Add the solid physics to the physics space
    // Attach solidnodes to rootnode
    ((SimpleApplication) app).getRootNode().attachChild(solidNodes);



Whats the code of FireBallControl ()?

@nehon, this guy has the same name as you

you can use bulletAppState.getPhysicsSpace().enableDebug(assetManager); to turn on showing collision meshes, the collision meshes might not look how you think they do.

Also if you use things like setLocalTranslation to move the fireball. the fireball will get forced through solid ground. The only way bullet stops anything from going through stuff is if its happening purely in simulation (eg you set an initial velocity and then the fireball moves on its own)

Hello, thank you for the replies. I will post the fireballcontrol code later, not at the pc atm.
I don’t use localtranslation to move the sphere. It’s a control I think that i give a starting speed, and it moves in a parabolic-shape. I thought it has something to do with the appstate, since all the other code has remain the same and it was working as expected without the appstate.
I will test with the collisionshape and post the results. Allready many thanks!