GhostControl collides with a 'bounding box' that doesnt exist

When I create a CharacterControl it collides with my mesh perfectly, but when I use a GhostControl and call getOverlappingObjects() it’ll return a collision with my mesh whenever it’s within my mesh’s ‘bounding box’.



Test case:

[java]public class WeirdCollisionTestCase extends SimpleApplication {

private static GhostControl ghost;

private Node ghostNode;

private BitmapText showText;



public static void main(String[] args) {

WeirdCollisionTestCase app = new WeirdCollisionTestCase();

app.start();

}



@Override

public void simpleInitApp() {

flyCam.setMoveSpeed(10f);

assetManager.registerLocator(“town.zip”, ZipLocator.class);

BulletAppState bulletAppState = new BulletAppState();

stateManager.attach(bulletAppState);

bulletAppState.getPhysicsSpace().enableDebug(assetManager);

Spatial sceneModel = assetManager.loadModel(“main.scene”);

CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(sceneModel);

RigidBodyControl landscape = new RigidBodyControl(sceneShape, 0);

sceneModel.addControl(landscape);

rootNode.attachChild(sceneModel);

ghost = new GhostControl(new CapsuleCollisionShape(0.75f, 4f, 1));

ghostNode = new Node();

ghostNode.addControl(ghost);

rootNode.attachChild(ghostNode);

bulletAppState.getPhysicsSpace().add(landscape);

bulletAppState.getPhysicsSpace().add(ghost);

showText = new BitmapText(guiFont);

showText.setLocalTranslation(0,100,0);

guiNode.attachChild(showText);

}



@Override

public void simpleUpdate(float tpf) {

ghost.setPhysicsLocation(cam.getLocation().add(cam.getDirection().mult(10)));

ghostNode.setLocalTranslation(cam.getLocation().add(cam.getDirection().mult(10)));

showText.setText(ghost.getOverlappingObjects().toString());

}

}[/java]

The capsule in front of the camera is the GhostControl. Fly the camera around to move it. A list of objects the GhostControl is colliding with appears in the bottom-left corner.

I’m having exactly the same problem. ¿Did you find the answer deadlyfugu?

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:bullet_pitfalls

Thanks for the quick reply! So, if I’m understanding that right, the GhostObject is taking town’s bounding box instead of the collision shape.



Thanks again, that link stopped a couple of headaches :slight_smile: