I’m trying to build a vehicle in UE4.27.2 using the native VehicleMovementComponent.
What has me stumped is how the suspensions move while driving. When I accelerate, the front suspensions compress and the rear suspensions extend. When I turn a corner, the outer suspensions extend and the inner suspensions compress.
Actual physics works exactly the opposite way. Accelerating moves load from the front wheels to the rear wheels, which should compress the rear suspension instead of extending it. Is this expected behavior for this component and if so, what can I do to make it behave like actual physics?
I don’t know much about Unreal (just got here!), but from a physics point of view it sounds like your centre of gravity is below the ground plane - can you check its position (rigid body) relative to the wheel colliders?
I actually do have an offset of my vehicle meshes center of mass and it is below the driving surface. I did that to stop the vehicle from constantly toppling over while turning.
I’ve also figured out in the meantime that effectively just the physics for vehicle is inverted on the Z-axis. I guess I could query their relative distance but I’m not sure what the goal with that would be?
I’ve also found out that this seems to be somehow specific to my vehicle mesh; using some example mesh from Epic (the Sedan from one of the example projects) I can see that the suspensions on that vehicle work correctly. Everything looked fine in Blender though, all axis pointing in the right direction.
If your car is a fairly normal road car, I’d suggest you place the centre of gravity (CoG) at a height of about 0.4m above the ground plane. Using tyres that behave like real world tyres this should slide before it rolls (unless you hit a trip obstacle).
I think it would be better to fix the CoG position rather than compensating for its effect on the suspension displacement measurement.
Is your mesh volume centre a large distance from the coordinate system origin for that mesh? Unfortunately, I am once again guessing here, as I have no UE vehicle experience: I’m sure that the mesh volume will be used to calculate the rigidbody inertia tensor - I’m not sure if UE uses that to re-calculate the CoG.
I’ve tried various heights for the center of mass offset, -80cm (i.e. 80cm below the vehicle body) was what I found to be good compromise between chassis stability and “feeling good to drive”. at -40cm it was very unstable and still regularly toppled over. The car is sort of a 1920s-style racing car with bicycle wheels.
Is your mesh volume centre a large distance from the coordinate system origin for that mesh?
Not terribly. I’m still trying to understand your line of reasoning here; why would moving the center of mass below ground invert my physics?
You physics isn’t really inverted, it’s just doing the opposite to what you expected
, but it is quite correct.
Edit: Cut for clarity, I think the cable car analogy is easier to understand.
For cornering think of a cable car suspended from a wire (where your wheels are) - it swings out, tipping the top of the car into the centre of the curve - the opposite of a normal road car, with its mass above ground, which rolls out away from the centre of the curve.
Your 1920s tyres will have less grip, but the cars are narrower and their CoG higher - I believe they were still inclined to slide before roll unless they hit a trip.
I think I understand the reasoning now, thanks!
Lowering the CoG is something I was recommended to do to combat the tendency to topple over, and it obviously makes sense that it helps. If the behavior I can see now is just an artifact of lowering the CoG too far, I’m not sure how I’m supposed to make this car stable enough to be of any use (excluding obvious solutions like using a mesh that has a naturally better ratio of CoG position and track width/distance between wheels).
Bummer. But at least it sort of makes sense now.