Collision detection problem

Hi, I am having some trouble with the collision detection with jme3. I have been following the tutorial, trying to test the collision detection with my own figure. But, when I think I have it down, I go straight through the object. Heres the method for it:
[java]public class Physics {

private Spatial sceneModel;
private RigidBodyControl landscape;
private CharacterControl player;

public Physics (Game game) {
    sceneModel = game.getAssetManager().loadModel("Models/bunny/bunny.j3o");
    game.getRootNode().attachChild(sceneModel);
    CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);
    landscape = new RigidBodyControl(sceneShape, 0);
    sceneModel.addControl(landscape);
    CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
    player = new CharacterControl(capsuleShape, 0.05f);
}

}[/java]
Is there something else that I need to include? Or…

Do you have the PhysicsAppstate in use? As far as I remember, you have then to add your controlls to it.

I changed my code a bit following the directions of the tutorial, and it still doesn’t work. Now I don’t really know what to do. Heres the new code:
[java]public class Physics {

private Spatial sceneModel;
private RigidBodyControl landscape;
private CharacterControl player;
private BulletAppState bulletAppState;

public Physics(Hyphadite hypha) {
    bulletAppState = new BulletAppState();
    hypha.getStateManager().attach(bulletAppState);
    sceneModel = hypha.getAssetManager().loadModel("Models/bunny/bunny.j3o");
    hypha.getRootNode().attachChild(sceneModel);
    CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);
    landscape = new RigidBodyControl(sceneShape, 0);
    sceneModel.addControl(landscape);
    CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
    player = new CharacterControl(capsuleShape, 0.05f);
    bulletAppState.getPhysicsSpace().add(landscape);
    bulletAppState.getPhysicsSpace().add(player);
}

}[/java]

I don’t see anything to associate the CharacterControl with a spatial. Is there a spatial associated with your player?

I don’t think so… I think I’m following all of the physics/collision steps in the HelloCollision tutorial. Do I need to include all of the other stuff like the keys and movement?

I think I made both objects solid, so why doesn’t it work? Sorry if it’s an easy answer, I’m kind of new to jme3.

Perhaps we don’t have enough information. Would you enable physics debugging and post a screenshot?

Instructions for physics debugging are here.

Instructions for screen shots are here.

I got a NullPointerException on the debugging line, and I tried putting it on both the Physics class and the main class, and I get the same thing. I am using private static PhysicsSpace physicsSpace; to use the debug method on your link.

From here your code and exception look ok (aka plz post the code and the excpetion + mark where it is thrown)

Heres the code:
[java]public class Hyphadite extends SimpleApplication {

private static Hyphadite hypha;
private static PhysicsSpace physicsSpace;

public static void main(String[] args) {

    hypha = new Hyphadite();
    hypha.setShowSettings(true);
    hypha.start();
}
public void simpleInitApp() {
    
    Physics physics = new Physics(this);
    Init_Map i_map = new Init_Map(this);
    physicsSpace.enableDebug(assetManager); //Line 23
}[/java]

Note: the enableDebug is deprecated now, is that why?
Heres the exception. It is thrown on the enableDebug line:
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at hyphadite.Hyphadite.simpleInitApp(Hyphadite.java:23)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:722)

physicsSpace is never set to anything so it’s null.

I fixed it, but I don’t really see a difference. Is the debugging the red lines of code in the output? I’ve been getting those every time I run the app. Heres the new code, in case I misplaced it or something:
[java]public class Physics {

private Spatial sceneModel;
private RigidBodyControl landscape;
private CharacterControl player;
private BulletAppState bulletAppState;
private PhysicsSpace physicsSpace;

public Physics(Hyphadite hypha) {
    physicsSpace = new PhysicsSpace();
    physicsSpace.enableDebug(hypha.getAssetManager());
    bulletAppState = new BulletAppState();
    hypha.getStateManager().attach(bulletAppState);
    sceneModel = hypha.getAssetManager().loadModel("Models/bunny/bunny.j3o");
    CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);
    landscape = new RigidBodyControl(sceneShape, 0);
    sceneModel.addControl(landscape);
    CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
    player = new CharacterControl(capsuleShape, 0.05f);
    hypha.getRootNode().attachChild(sceneModel);
    bulletAppState.getPhysicsSpace().add(landscape);
    bulletAppState.getPhysicsSpace().add(player);
}

}[/java]

“new PhysicsSpace();” won’t work unless you’ve already created a BulletAppState.

The customary procedure to acquire a PhysicsSpace instance is:

    bulletAppState = new BulletAppState();
    getStateManager().attach(bulletAppState);
    PhysicsSpace space = bulletAppState.getPhysicsSpace();

I added the third line, for I already had the first two. Still doesn’t work. Updated Code:
[java]public class Physics {

private Spatial sceneModel;
private RigidBodyControl landscape;
private CharacterControl player;
private BulletAppState bulletAppState;
private PhysicsSpace physicsSpace;

public Physics(HyphaDex hypha) {
    physicsSpace.enableDebug(hypha.getAssetManager());
    bulletAppState = new BulletAppState();
    PhysicsSpace space = bulletAppState.getPhysicsSpace();
    hypha.getStateManager().attach(bulletAppState);
    sceneModel = hypha.getAssetManager().loadModel("Models/bunny/bunny.j3o");
    CollisionShape sceneShape = CollisionShapeFactory.createMeshShape((Node) sceneModel);
    landscape = new RigidBodyControl(sceneShape, 0);
    sceneModel.addControl(landscape);
    CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
    player = new CharacterControl(capsuleShape, 0.05f);
    hypha.getRootNode().attachChild(sceneModel);
    space.add(landscape);
    space.add(player);
}

}[/java]

Your problem isn’t collision detection, I think you need to be better at basic java or nothing will make sense. Maybe this will help: http://docs.oracle.com/javase/tutorial/java/index.html