What I'm trying to do is create a track out of a number of "ground" pieces placed side by side in a row. This is all good and works a treat.
What I then do is add a number of boxes along this track.
The problem is that if the boxes fall on the first piece of track they collide with it and behave normally. If they fall on any other piece of track they fall straight through.
However if i set the ground sections to DISABLE_DEACTIVATION everything works fine. This is not good though as the application doesn't behave well with everything active all the time.
Am I missing something obvious?
Code: Select all
public void initLevel() {
createConveyor();
// first box
createEggBox(new Vector3(0, 10, 0));
// second box
createEggBox(new Vector3(15, 10, 0));
}
Code: Select all
private void createConveyor() {
Vector3 offset = new Vector3(0, 0, 0);
Vector3 offsetAdd = new Vector3(32f, 0, 0);
for (int i = 0; i < 5; i++) {
GameObject object = GameObjectFactory.getGameObject(ObjectType.CONVEYOR);
object.body.setCollisionFlags(object.body.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
object.transform.trn(offset);
object.body.setUserValue(objectManager.instances.size());
objectManager.instances.add(object);
objectManager.bulletHelper.dynamicsWorld.addRigidBody(object.body);
object.body.setContactCallbackFlag(GROUND_FLAG);
object.body.setContactCallbackFilter(ALL_FLAG);
offset.add(offsetAdd);
}
}
Code: Select all
private void createEggBox(Vector3 offset) {
GameObject obj = GameObjectFactory.getGameObject(ObjectType.EGG_BOX);
obj.transform.setFromEulerAngles(MathUtils.random(360f), 0, 0);
obj.transform.trn(0, 2f, 0).trn(offset);
obj.body.proceedToTransform(obj.transform);
obj.body.setUserValue(objectManager.instances.size());
obj.body.setCollisionFlags(obj.body.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK);
obj.body.setContactCallbackFlag(OBJECT_FLAG);
obj.body.setContactCallbackFilter(ALL_FLAG);
objectManager.instances.add(obj);
objectManager.bulletHelper.dynamicsWorld.addRigidBody(obj.body);
}