Additionally, it looks like your hull shape is way too low, making it bump into the ground when the suspension is compressed.
This is what you want
Heāll probably say āthis is just the Google Doc that is linked in the javadoc and wiki, I donāt understand how that is supposed to help me.ā
Well, thereās nothing there specifically related to vehicle roll, other than setRollInfluence(), which does not affect anything when used in my code.
I have been using JBullet for over 4 years, read the wiki pages, etc. However I simply cannot find anything to solve this specific problem.
(I guess what Iām saying is, why would I have come here without researching the issue first?)
That doesnāt mean Iām a good programmer though⦠So feel free to point out the thing that magically solves my issue which I have totally missed.
Am currently experimenting with stabilizer wheels. Only problem is, they are bad in confined spaces.
I told you what the problem in the video is (the chassis bouncing into the ground) and how you can change the center of mass, which is what ALL games do to make their vehicles more stable⦠Funny how so many people got working non-rolling cars in less than 4 yearsā¦
[quote=ānormen, post:25, topic:36948, full:trueā]How you can change the center of mass
[/quote]
This is my problem - I canāt work out how to do it. I can put the collision shapes higher up, but then my car associated with the collision shape still stays in the center, which now clips through the terrain⦠And I cannot work out how to put a node at a huge bias higher up.
I mightāve been using JBullet for 4 years, but Iāve only been using JME since January. Donāt expect a JME expert here.
Just because Iāve been using JBullet for 4 years doesnāt mean Iāve worked with cars for 4 years. It is only in the last three or four months I have used cars at all - I was previously working on a plane game.
Umm⦠you say you donāt know how to move a Spatial that is attached to a Node? Then you shouldnāt be messing with physics yet at all⦠Anyway, I copy-pasted the relevant code from TestPhysicsCar and added the secret code to attach a model to that node with an offset (but donāt show this to anybody else, its occult knowledge!)
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
//this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0
CompoundCollisionShape compoundShape = new CompoundCollisionShape();
BoxCollisionShape box = new BoxCollisionShape(new Vector3f(1.2f, 0.5f, 2.4f));
compoundShape.addChildShape(box, new Vector3f(0, 1, 0));
//create vehicle node
Node vehicleNode=new Node("vehicleNode");
vehicle = new VehicleControl(compoundShape, 400);
vehicleNode.addControl(vehicle);
// MYSTERIOUS WAY TO ADD MODEL HERE!!
Spatial vehicleModel = assetManager.loadModel("Models/MyCar.j3o");
vehicleModel.setLocalTranslation(0,1,0);
vehicleNode.attachChild(vehicleModel);
Edit: Oh and remember, your hull is still bouncing into the ground, put your wheels further down.

Umm⦠you say you donāt know how to move a Spatial that is attached to a Node? Then you shouldnāt be messing with physics yet at all⦠Anyway, I copy-pasted the relevant code from TestPhysicsCar and added the secret code to attach a model to that node with an offset (but donāt show this to anybody else, its occult knowledge!)
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0 //this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0 CompoundCollisionShape compoundShape = new CompoundCollisionShape(); BoxCollisionShape box = new BoxCollisionShape(new Vector3f(1.2f, 0.5f, 2.4f)); compoundShape.addChildShape(box, new Vector3f(0, 1, 0)); //create vehicle node Node vehicleNode=new Node("vehicleNode"); vehicle = new VehicleControl(compoundShape, 400); vehicleNode.addControl(vehicle); // MYSTERIOUS WAY TO ADD MODEL HERE!! Spatial vehicleModel = assetManager.loadModel("Models/MyCar.j3o"); vehicleModel.setLocalTranslation(0,1,0); vehicleNode.attachChild(vehicleModel);
Hm. Interesting I didnāt think of that.
Meh.

Edit: Oh and remember, your hull is still bouncing into the ground, put your wheels further down.
What makes you believe that? The collision model is nowhere near the ground and never has been. If youāre referring to the visual model, then Iām using a different collision model.

What makes you believe that? The collision model is nowhere near the ground and never has been. If youāre referring to the visual model, then Iām using a different collision model.
The fact that in your GIF the suspension stops compressing when the vehicle falls over.
@normen Setting the centre to be lower simply isnāt working. it completely messes up car rotation in terms of pitch and roll, as it is trying to pitch forward from a center point way below the actual physics. It creates very bad looking unnatural physics.
Thank you for the suggestion anyway, but stabilizer wheels appear to be the much better option.
Thanks all. Will try to find a more permanent solution for the future.
Wheels outside of the hull will create all kinds of other issues. Try driving along a wall with your stabilizer wheels. Setting the center of mass lower is definitely working, thats why ALL games do it. But anyway, Iāll drop out of this thread now. Good luck with your game.

Wheels outside of the hull will create all kinds of other issues. Try driving along a wall with your stabilizer wheels. Setting the center of mass lower is definitely working, thats why ALL games do it. But anyway, Iāll drop out of this thread now. Good luck with your game.
Alright. Will attempt to lower the center of mass when I have time. I can see why it is a viable solution - Perhaps I just lowered it too much.
Luckily I donāt have many any walls in my game. But, when I do, then I see your point.
Thanks for the assistance. Appreciate it.
And maybe try to set the āinertia tensorā in the bullet physics engine. Thatās basically a matrix which contains the integral (or āsumā) of mass elements along all three major axes. Set it in such a way that most of your mass elements are near the bottom of the vehicle and closer to the engine block.
Donāt know if setting the com (center of mass) is equivalent to this solution and if itās even possible with bullet to set the inertia tensor. The book about physics that I read described a physics engine that letās you set the inertia tensor and it contained several examples like boxes, bottles, etc.