Crash on getPhysicSpace

I’m trying to load a spatial into my collision space but everytime I get a crash.

[java]

bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);

player = new BetterCharacterControl(1f,6f,1f);
player.setJumpForce(new Vector3f(0, 0, 0));
player.setGravity(new Vector3f(0, -10, 0));
player.warp(new Vector3f(0, 75, 0));
toon.setLocalTranslation(0, 75, 0);
toon.addControl(player);
bulletAppState.getPhysicsSpace().add(toon);
bulletAppState.getPhysicsSpace().add(player);
bulletAppState.getPhysicsSpace().add(prison);

[/java]

The crash occurs on the last line when I’m adding the prison spatial. I can comment this line out and everything will load fine and I warp to (0,75,0) Then start falling through my environment because the prison isn’t added to the physics. Not sure if this helps.

at com.jme3.bullet.PhysicsSpace.add(PhysicsSpace.java:377)
at mygame.prisonbreak.setupcollision(prisonbreak.java:191)
at mygame.prisonbreak.initialize(prisonbreak.java:84)
at com.jme3.app.state.AppStateManager.initializePending(AppStateManager.java:251)
at com.jme3.app.state.AppStateManager.update(AppStateManager.java:281)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:239)
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)

you missed out on a bit of the stack trace (the exception). If it’s a NPE, did you check that prison is not null?

If by “crash” you mean an exception, it might be helpful to know the type of exception.

It might also be helpful to know which version of JME3 you’re running.

If it’s a NullPointerException in a recent ‘master’ build (not stable/3.0.9), then the source code (available from

suggests that the problem is a spatial which lacks a PhysicsControl.

Add a PhysicsControl to ‘prison’ and the crash should go away.

Thanks it seems I had to add a control to it. However the prison is a static object that doesn’t move and doesn’t need a control. Can you add just the geometry of the spatial to the physics space ? I tried to do that using the original collision tutorial code but with no success.

Controls serve many different purposes. They aren’t just for animation.

You could add shape (not the geometry) to physics space without creating a control, but that doesn’t gain you anything as far as I can see. Controls are cheap.