Collision not working, after Adding RigidBodyControls to a node

Hello monkeys :slight_smile:

In our project we have specific classes for several LevelElements (like Straights, Curves, Forks or DeadEnds) wich contain one node each with multiple RigidBodyControls added to them. When i try to add these to the PhysicsSpace, there is no error, like a NullPointer or sth that would occour, when there is no Control attached to the node, but the Collision does not work either, i can just “walk through the walls”.

The code for adding the RigidBodyControls to the spatial, (is called after the Node has been added to rootNode) looks like this:
[java]
@Override
protected void addCollisionControlsToNode() {
//------------------PHYSICS und COLLISION--------------------------------------
//Create Collisionshapes for all walls, considering the vertex-arrays defined above
SimplexCollisionShape wallLeftShape = new SimplexCollisionShape(
verticesLeftWall[0], verticesLeftWall[1], verticesLeftWall[2], verticesLeftWall[3]);
SimplexCollisionShape wallRightShape = new SimplexCollisionShape(
verticesRightWall[0], verticesRightWall[1], verticesRightWall[2], verticesRightWall[3]);
SimplexCollisionShape floorShape = new SimplexCollisionShape(
verticesFloor[0], verticesFloor[1], verticesFloor[2], verticesFloor[3]);
SimplexCollisionShape ceilingShape = new SimplexCollisionShape(
verticesCeiling[0], verticesCeiling[1], verticesCeiling[2], verticesCeiling[3]);

   //Create RigidBodyControls
    RigidBodyControl wallLeftControl = new RigidBodyControl(wallLeftShape, 0);
    RigidBodyControl wallRightControl = new RigidBodyControl(wallRightShape, 0);
    RigidBodyControl floorControl = new RigidBodyControl(floorShape, 0);
    RigidBodyControl ceilingControl = new RigidBodyControl(ceilingShape, 0);
    
    wallLeftControl.setApplyPhysicsLocal(true);
    wallRightControl.setApplyPhysicsLocal(true);
    floorControl.setApplyPhysicsLocal(true);
    ceilingControl.setApplyPhysicsLocal(true);
    
   //Add these to the node
    this.node.addControl(wallLeftControl);
    this.node.addControl(wallRightControl);
    this.node.addControl(floorControl);
    this.node.addControl(ceilingControl);        
}    

[/java]

Afterwards they are being added to PhysicsSpace from within a central function that traverses our LevelElements using:
[java]
bulletAppState.getPhysicsSpace().add(spatial);
[/java]

Creating a simple box and adding this to the PhysicsSpace works by the way.

This is why I assume, that the error may be caused by fact, that the Controls are not being added to the Geometries which define that particular wall like “wallLeft”, but are instead added to the parent node, that contains these geometries and describes the whole LevelElement.
But on the other hand I remember having seen people add Controls directly to nodes, like we do it in our code and I would like you to give me an estimation if this may be the problem or not, before i refactor 50% of our existing code just to recognize, that the mistake was something perfectly different.

So do you think, my theory could be right or does your experience tell you several other common reasons for collision code to misbehave, like mine does?

I will be glad about hints and suggestions of every kind. Thank you.

Best regards

mank319

What is your other party which is colliding? Is it a mesh collisionshape? because mesh/mesh collisions are not supported, which would back up your statement that using a box works. I’ve never used a SimplexCollisionShape before tho, if you do collisionshape.gettype() (can’t remember what the method is called), it should tell you if a SimplexCollisionShape is a mesh shape or not. And if your other shape is a mesh shape then the collisions won’t occur.

Thank you again :slight_smile:

In my case, the other party is the “player” with the following collision code:
[java]
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 18f, 1);
this.player = new CharacterControl(capsuleShape, 0.05f);

    player.setPhysicsLocation(new Vector3f(0, 15, 0));
    bulletAppState.getPhysicsSpace().add(player);

[/java]
So I guess, that shall not be the problem, right?
Any other “typical mistakes” that you know of, when it comes to collision? :slight_smile:

hmmmm, i’m not sure. Like I say, i’ve never used SimplexCollisionShape before, does the shape appear when using the Physics Debug? I notice your character is 18 meters tall, but otherwise not sure