# Vehicle Dynamics: Center of Gravity and Anisotropic Tire Friction?

The UE vehicle seems to have some “magic” forces that make it very hard to flip a car over, even if I deliberately try to by going fast with the left half onto a ramp, or setting tire friction high and making abrupt turns.

In other physics engines, I’ve made arcade cars that have good handling with rays for wheels, a physics box for the body/chassis, and a low-but-not-bottom center of gravity. Plus appropriate anisotropic friction and slip coefficients for the contact patches. How close to that can I get in the UE vehicle model? Specifically, changing the COG and changing the tire contact patch friction anisotropically, as well as turning of any “magic” forces, would be very helpful – is that exposed, and to what parameters?

Hi,

Have you tried playing with the inertia tensor of the car? Specifically along the x-axis?
When you say the car is hard to flip over, do you mean while the tires are still touching the ground? Or even when the car is in the air?
I suspect that when the tires are still touching the ground there might be some bad behavior caused by the fact that the tires are using a simple ray cast and (perhaps) don’t consider the tire’s tipping point.

Would you be able to post a video/gif? This would help narrow down the problem so we can fix it.

Thanks!

I have not played with this – is it by default something scary, like infinite?
The behavior I’m seeing seems to be self-righting, though – the car seems to have a center of gravity that is below the ground; it rotates unnaturally.

Rays can generate fantastic driving simulation, if you do some work to properly simulate an anisotropic contact patch and suspension forces, and put the center of gravity of the car a little bit above the tire contact plane.
If you think of the ground contact as a plain contact, with very low friction in the direction the tire is pointed (or even a linear motor in that direction) and much higher friction (but some slip) in the sideways direction, “tipping” simply happens when the sideways force from the center of gravity of the chassis moving into the turned wheel is enough to lift/twist the car.
The ODE library contact joint with linear motor support is perfect for this (because it solves in velocity space); I don’t know how detailed you can get with contact joints/patches in PhysX?
I’ll see if I can get a recording of the behavior I mean.

Yeah, I’m having a hard time making vehicles behave more realistically as well…

Beside the issues jwatte is describing, I have a question:

How do you make a vehicle sway and tilt when accelerating or braking? No matter how I set the suspension, the chassis always stays completely leveled. It looks really unnatural even with the monster truck from your sample game…

To make the chassis lean, turn down the suspension offset force to -25 or so for both front and rear wheels.

I tried recording the self-righting behavior of the vehicle template game, but it turns out mobile GeForce gpus can’t record desktop apps

Jwatte, do you have any thought on how “anisotropic contact patch” can be done in UE4? Or how it’s usually done in physics engines.
If I remember correctly, Bullet have implementation of anisotropic friction out of the box, but unfortunately UE4 seams to be lucking in this field. I’m planning to code it in, but not sure where to begin.

Because they use PhysX and only expose a subset of it, you cannot do it on your own unless you can create a fully custom constraint.

The physics engine I’ve had the easiest time building a good car in is ODE. In the ODE physics engine, I do a ray-based tire contact by:

1. Specifying a “forward” vector
2. Specifying the anisotropic friction flag
3. Setting the “forward” and “sideways” friction values
4. Setting a “linear motor” for the rolling/braking speed of the tire
5. Specifying a little bit of “slip” along the sideways vector, to model tread deformation

(Suspension can also be modeled as a pushing-outwards force with some spring and damping constants)

The ODE library then turns this into the appropriate constraints for the physics solver. IIRC, ODE works in velocity space, which means that the options above can be translated into a desired change-in-velocity for this contact, which in turn goes into the big matrix of all constraints that the engine solves.

The PhysX library does have support for a D6 joint (user-specified rotation and translation allowed) and for a fully custom constraint. If you are using C++, you could start looking there.

Thank you for taking time to reply!
I’ll look into custom constraint, hopefully it can be exposed under the UE4 framework.