Ghost control

Quick question,

I am rotating a X-node attached with a cube. I attached a ghost control object with a Y-node which in turn is connected to the X-node. Now as the X-node rotates, the Y-node rotates. Now running the code, I can clearly see the cube and the ghost-object parallel to each other with a fair amount of distance between them. But the getOverlappingObjects() method keeps returning me a collision?

strange, could you post a screenshot with [java]bulletAppState.getPhysicsSpace().enableDebug(assetManager);[/java] turned on thanks



and also the code your using to create the controls and the code for checking for collisions

Thanks for your reply. I’m new to all this so please bear with me.



Here’s the screenshot. You can clearly see the ball and the board are away from the GhostCube below but at this position it’s telling me the ball AND the board both are colliding with the GhostCube.



http://i.imgur.com/CY0s8.png



Here are the relevant bits of code.





Node pivot = new Node(“pivot”);

Node wrongNode = new Node(“wrongNode”);

Node rightNode = new Node(“rightNode”);





private RigidBodyControl board_phy;

private RigidBodyControl ball_phy;

private static final Sphere sphere;

Geometry ball = new Geometry(“Ball”, sphere);

GhostControl WrongHole = new GhostControl(new BoxCollisionShape(new Vector3f(7f, 0.2f, 4f)));





rootNode.attachChild(pivot);



Spatial Board = assetManager.loadModel(“Models/WoodBoard/WoodBoard.scene”);

board_phy = new RigidBodyControl(0f);

Board.addControl(board_phy);

bulletAppState.getPhysicsSpace().add(board_phy);

board_phy.setFriction(20.0f);

board_phy.setKinematic(true);



bulletAppState.getPhysicsSpace().add(WrongHole);



rightNode.addControl(RightHole);



wrongNode.setLocalTranslation(0,-3f,0);



pivot.attachChild(wrongNode);

pivot.attachChild(Board);







public void simpleUpdate(float tpf) {

if (WrongHole.getOverlappingObjects().contains(ball_phy))

{

System.out.println(“Ball Detected!!”);

//Reset();



}

if (WrongHole.getOverlappingObjects().contains(board_phy))

System.out.println(“Board Detected”);

}

You create a mesh collision shape by giving the RigidBody a mass of zero. Meshes are not meant to be dynamic (movable), the ghost control only uses the bounding box of the shape to test for collisions.