# How do I stop my physics car from easily flipping over?

Hello all,

I am using a VehicleControl, adding the player model to it, and then adding the wheels.

However I have a problem. When turning, especially at high speeds, the vehicle flips over very easily.

How can I make the vehicle more stable, so that it does not flip over? Something like a angle limitation would be great (but I can’t get this to work because rotation is in quaternions and I have to convert it to vehicle rotation and other garbage), but I would really prefer to stop jBullet from trying to flip the car over in the first place.

TL;DR - How do I stop a VehicleControl from flipping over so easily when turning?

Does changing mass effects the behavior?

1 Like

I think this is the expected behaviour for a really heavy tank running as fast as a racing car.
I may be wrong, but my guess is, since the mass is the resistance of a change of motion, when you turn the tank since the mass is high it tries to keep it’s motion (and roll because the friction of the wheels?).

3 Likes

Lower the center of gravity.

No, lower than that.

2 Likes

add some stickers to the tank, any car guy knows stickers add performance, should help with the flipping and add much needed power.

1 Like

Also the suspension stiffness is key here, but leads to lifting wheels then.

There is a Word Document around with some Setup Info since good Driving behaviour isn’t easy

When the tank starts to roll, have the whole world and the camera roll with it, so that nobody will notice… ok, I’ll shut up.

4 Likes

How do I do that? The collision model is already as low as it can get without hitting the ground.

No, not at all. I tried a mass of 1 and a mass of 100, behaviour is unaffected.

I have been experimenting a bit:

``````w.setRollInfluence(1f);
``````

Does absolutely nothing.

``````w.setFrictionSlip(0.4f);
``````

Makes the vehicle very slippy and hard to control - However it is impossible to flip over (perhaps your friction idea was right?).

Increasing the mass or gravity doesn’t seem to do anything… Which seems odd to me. And increasing suspension stiffness just results in buggy behaviour.

I still cannot find a solution to the issue.

The center of mass is the center of the collision shape. Make a compound shape, add the collision shape for the car hull with an up offset, attach the model to a node with the same offset and then add the compound shape to the node. This way the center of mass will be at the node, below the actual model and collision shape.

Mhh, as a workaround you can artificially add an opposite force when you turn, or maybe on top of the vehicle to keep it stuck to the ground.

1 Like

I am actually struggling to achieve this. Could you please give a little bit of code to help me along my way?

Using BoxCollisionShape vehicle will never roll. Then make a CompoundCollisionShape out of box shapes.

Tried that, does not work.

Hello, you may want to do some research on anti-roll bars (also called sway bars) in vehicles.

That’s just JMETest’s TestPhysicsCar. I don’t understand how that is going to help me stop my car flipping over? Especially as most of my existing code is practically copied from there anyway and so is almost identical.

Edit: If anything, the car in TestPhysicsCar flips over EVEN MORE than my one!!

I know what I posted, yes. You asked me a specific question, I gave an answer and then you wanted example code for what I said. Look at line 102 in the file I posted.

Also you may look at TestFancyCar.java
just tested it and car not rolls.