Vehicle CollisionShape jiggles about relative to vehicle mesh

I’ve largely followed the code from Controlling a Physical Vehicle and and I’ve got a little red vehicle mesh driving around a custom-made racetrack.

But with bulletAppState.setDebugEnabled(true) showing the CollisionShape, I can see that the CollisionShape jiggles about relative to the actual graphical vehicle mesh, so that at some points the CollisionShape is adrift by as much as twenty percent of the vehicle width. Periodically the CollisionShape will then pop back into place so that it’s perfectly aligned with the rendered vehicle mesh again.

Is this jiggle/drift expected, or is it likely that I’ve done something wrong when creating the vehicle and the physics control?

The method which creates the vehicle is:

private void initVehicle() {
    carNode = new Node();
    Spatial carModel = assetManager.loadModel("Models/bareCoop.j3o");
    Spatial carSpatial = findSpatial(carModel, "chassis_node");
    Geometry carBody = findGeom(carModel, "chassis");
    HullCollisionShape vehicleShape = new HullCollisionShape(carBody.getMesh());
    CompoundCollisionShape compoundShape = new CompoundCollisionShape();
    compoundShape.addChildShape(vehicleShape, new Vector3f(0, 0, 0));
    compoundShape.addChildShape(new BoxCollisionShape(new Vector3f(0.6f, 0.2f, 1.0f)), new Vector3f(0, 0.6f, 0));
    player = new VehicleControl(compoundShape, 121.80f);

Probably it is a bug, any jiggling of car is not expected. Now I can’t imagine how your vehicle is looking with collision mesh. Only I can help you now is, if you want a box collision shape around your car or perfect collision mesh, that is the same shape of your vehicle. I haven’t seen this complicated code before.

Edit: jiggles is expected only when you are going very fast, then collision mesh is going slight behind of spatial, it’s showing with debug enable, but mesh is in its place. It’s because rendering debug is little bit slowly.

Ah, you think maybe it’s just the debug render being drawn a little out of time?

Regarding the CompoundCollisionShape this is being used because I found (thanks to a post on this forum) that unless the start point of the suspension is within the CollisionShape the vehicle will sink into the ground with even a tiny bit of force, so that the wheels get stuck below the track. The extra box being added to the CollisionShape here is just a suspension guard which contains the suspension start points to protect them.

I haven’t got any guards shapes on my cars and they didn’t sink into the floor. Just an opinion.

If you can see it when you are moving with vehicle that debug collision is behind the car, it’s it.

But if it’s doing anything to car, like the car is not stable and you spot collision mesh not at its place when you stop the vehicle, it means there is a problem.

I’m sorry, but I don’t know what you mean under jiggling and how CollisionShape can “adrift by as much as twenty percent of the vehicle width.”

I can say more, if you post short video or gif of your vehicle jiggling.