Problem with box collision shape

Hey all.
At first, sorry if there is any similiar topic but I can’t find answer for my problem anywhere :frowning:

So, I want to improve performance of my game. I am thinking about adding box collision shapes to my static models in scene, instead of using standard collision shape (just copy of model).

Here is example how I want to do is :

        Spatial chair = assetManager.loadModel("Models/chair.mesh.xml");
        
        CollisionShape shape = CollisionShapeFactory.createBoxShape(chair); // instead of createMeshShape(chair)
        RigidBodyControl chairControl = new RigidBodyControl(shape, 0f);
        chair.addControl(chairControl);
        
        bulletAppState.getPhysicsSpace().add(chairControl);
        rootNode.attachChild(chair);

And this is my issue:

As you can see, collision shape doesn’t fit to chair, is any alternative way to make it right? Thanks fort tips :slight_smile:

The center of the shape is at the center of the model, so you have either to move it on your model or make a compound collision shape and add an offset to your box shape

1 Like

CompoundCollisionShape fixed it. An Offset needs to be set to Y extent of spatial bounding box.

Thanks :slight_smile: