[SOLVED] How to stop physicscar's flip over?

Hello,In Testphysicscar.java when i steer car on high speeds it is flipping over.Is there a way to stop flipping over of car?

1 Like

Maybe you can try to reduce the friction of the wheels?

1 Like

Changing friction of wheels affects car steering it doesnt look normal.

1 Like

https://hub.jmonkeyengine.org/search?q=vehicle%20flip%20over?

1 Like

I read related topics before creating this topic.They dont have specific solution and just talking about changing center of mass.I dont know how to change center of mass.

1 Like

The center of mass is always at the center of the physics object (i.e. the point that moves to 0/0/0 if you move the object to 0/0/0). To offset the center of mass you offset the collision shape. So if the object is at 0/0/0 and you add the collision shape at 0/1/0 the center of mass is effectively at 0/-1/0 (relative to the collision shape)

1 Like

If I understand right you are saying change the code on line 106
compoundShape.addChildShape(box, new Vector3f(0, 1, 0)); .
But when i reduce its y axis ,it change the place of collisionshape too.I want to use collision shape on up because i have atv model(its car body on upper place in comparison to fancy car) and want to use it as a physics car.

1 Like

And also, setting a car up for perfect gravity, balance, just the right amount of rear slip, etc… is all a bit of an art in itself. It will require tedious amounts of fiddling without a simple gui debug screen to get right. Its what makes a ferrari a ferrari, and an aston martin a ‘wonderful to drive’ big fat tank on wheels.

2 Likes

I am searching possible solutions for a couple of day.Can I make it by applying impulse which direction is ground on car or wheels?When i apply impulse on car its wheels are getting under the floor.

1 Like

Setting rollinfluence of every wheel to 0 works for me.But now when i brake it is flipping over on z axis.I configured brakes and now only back wheels of car brakes, it is not flipping over on z.But it’s rotation is changing when i brake
in the speeds more than 50 km/h.

1 Like

The solution IS moving the center of mass.

1 Like

As I said before changing center of mass also changes place of collision shape.I want to use collision place on it’s right place.Also even when i change it is center of mass it is rolling over easily because of car’s collisionshape bottom not square(it has round bottom).You can think my car as a normal physics car only difference is it’s wheel yOff is -0.5f .

1 Like

Not according the tutorial.

Best Practice: We attach the BoxCollisionShape (the vehicle body) to the CompoundCollisionShape at a Vector of (0,1,0): This shifts the effective center of mass of the BoxCollisionShape downwards to 0,-1,0 and makes a moving vehicle more stable!

compoundShape.addChildShape(box, new Vector3f(0, 1, 0));

That’s from here: https://jmonkeyengine.github.io/wiki/jme3/advanced/vehicles.html#creating-the-vehicle-chassis

1 Like

But it result with move on collision shape.Tutorial just say it makes more stable.

1 Like

But that’s what you’re looking for. Stability.

Give it a whirl regardless and see what happens.

1 Like

I will implement my atv on physics car that is why collision shape’s place is important for me to listen collision detection of atv.Setting roll influence to 0 works well for me.But brakes are still problem.

1 Like

The braking results in flipping… Which is due to your center of mass being too high. :expressionless:

1 Like

You don’t get it. You have to move the center of mass, not the collision shape itself. So the shape has to move up when you move its center down… The center of a collision shape is always its center of mass.

To create a collision shape with its center of mass outside of its volume:

  • Create a node “A” at 0/0/0
  • Attach a box “B” at local translation 10/0/0
  • Make a collision shape from node “A”.
  • Now note how the collision shape looks like a box at 10/0/0 but its center of mass is at 0/0/0

This is because of what was said repeatedly now - the collision shape always has its center of mass at its origin. The collision shape was generated from the node at 0/0/0, so thats its origin. The volume or mesh of the collision shape was at 10/0/0 though, so thats where you see it and bump into it.

2 Likes

@normen I have tried to code like you said and also set yoff of wheel to -.5f . This is my code it is in buildplayer function.
Box b=new Box(1.2f,0.5f,2.4f);
Geometry geom = new Geometry(“Box”, b);
geom.setLocalTranslation(0, 10, 0);
geom.setMaterial(mat);
Node z=new Node();
z.attachChild(geom);
z.setLocalTranslation(0,0, 0);
CollisionShape carHull = CollisionShapeFactory.createDynamicMeshShape(z);
Node vehicleNode=new Node(“vehicleNode”);
vehicle = new VehicleControl(carHull, 400);
vehicleNode.addControl(vehicle);

Am i doing it wrong?

If it doesn’t work then yes, you are doing it wrong.

1 Like