May be it is because control.setGravity(new Vector3f(0, -98f, 0)); -98 is to much It should be -9.8f also for your player player.setGravity(98f); → player.setGravity(9.8f);
also you better to use HullColisionShape for your terrain collision shape.
It works fine will simple Box mesh, dynamic rigid body don’t pass through it.
But when I tried to create a HullCollisionShape will complex mesh it didn’t work.
private List<RigidBodyControl> terrainHulls;
@Override
protected void initialize(Application app) {
// the other code...
// Terrain
if (useHullCollision) {
model.breadthFirstTraversal(new SceneGraphVisitor() {
@Override
public void visit(Spatial spatial) {
if (spatial instanceof Geometry) {
Mesh mesh = ((Geometry) spatial).getMesh();
terrainHulls.add(new RigidBodyControl(new HullCollisionShape(mesh), 0));
}
}
});
} else {
CollisionShape shape = CollisionShapeFactory.createMeshShape(model);
terrain = new RigidBodyControl(shape, 0);
}
}
@Override
protected void onEnable() {
simpleApp.getRootNode().attachChild(rootNode);
getStateManager().attach(bulletAppState);
// terrain
if (useHullCollision) {
for(RigidBodyControl control : terrainHulls) {
bulletAppState.getPhysicsSpace().add(control);
}
} else {
bulletAppState.getPhysicsSpace().add(terrain);
}
// the other code..
}
It look like I didn’t generate HullCollisionShape properly. I lost the information of transform.
You will be happiest if your geometry is 1 unit = 1 meter. Then all of the other numbers like gravity will make more sense.
Quite often games will double the gravity, though, because for some reason in a game realistic gravity feels to floaty. Several game physics books I’ve read have mentioned this. 20 is an often used gravity value.
Do not use real physical objects for anything actually fast!
Instead do a raycast each game tick, and move the bullet in code if it is clear (or hit whatever it did hit)
It’s better to avoid ccd if possible, because it may slow down the simulation a lot. Try to make the collsion shape a little bigger and to use a simple shape like sphere instead of hull for the bombs.