Hello there,
Im trying to create a forklifter simulator, where you pick up a pallet. The problem is, that sometimes the forks moving through the pallet. Ive made a short clip.
I use multiple box shapes added in CompoundCollisionShape for the pallet and the fork. Thats my code for the pallet:
debugmodel = assetManager.loadModel("Models/eup/eup.j3o");
debugmodel.setLocalScale(0.4f);
debugmodel.setLocalTranslation(12f, 0.5f, 12f);
CompoundCollisionShape sceneShape = new CompoundCollisionShape();
// four corners
BoxCollisionShape box_ground = new BoxCollisionShape(new Vector3f(0.11f, 0.11f, 0.11f));
sceneShape.addChildShape(box_ground, new Vector3f(0.6f, 0.11f, 0.85f));
sceneShape.addChildShape(box_ground, new Vector3f(-0.6f, 0.11f, -0.85f));
sceneShape.addChildShape(box_ground, new Vector3f(-0.6f, 0.11f, 0.85f));
sceneShape.addChildShape(box_ground, new Vector3f(0.6f, 0.11f, -0.85f));
// top plane
BoxCollisionShape box_top = new BoxCollisionShape(new Vector3f(0.71f, 0.02f, 0.94f));
sceneShape.addChildShape(box_top, new Vector3f(0, 0.24f, 0));
RigidBodyControl item_phy = new RigidBodyControl(sceneShape, 0.1f);
debugmodel.addControl(item_phy);
rootNode.attachChild(debugmodel);
bulletAppState.getPhysicsSpace().add(item_phy);
And this is the part for the forks from the vehicle. The forkerFrontPart is a ChildNode from the main vehicle:
forkShapes = new BoxCollisionShape[2];
CompoundCollisionShape box_forker = new CompoundCollisionShape();
// bottom plane
box_forker.addChildShape(forkShapes[0] = new BoxCollisionShape(
new Vector3f(1.15f, 0.1f, 1.8f)), new Vector3f(-0.0f, -1.15f, 1.95f));
// back plane
box_forker.addChildShape(forkShapes[1] = new BoxCollisionShape(
new Vector3f(1.15f, 0.8f, 0.1f)), new Vector3f(-0.0f, -0.45f, 0.15f));
RigidBodyControl fork = new RigidBodyControl(box_forker, 0);
fork.setEnabled(true);
fork.setKinematic(true);
forkerFrontPart.addControl(fork);
bulletAppState.getPhysicsSpace().add(forkerFrontPart);
I tested to make the pallet bigger, but same result. Its bouncing sometimes or jumping out of the map.
Any Ideas to solve this? Are there better solutions to make a collisionshape for this things?
Thx