Vehicle Controller

This controller is used to create a wheeled vehicle like a car. The car body is a rigid body and each wheel is simulated by a raycast. The ray's intersection point is used to calculate the suspension length and the suspension force. The suspension force is used to stop the body from hitting the ground. For each wheel ray that hit the ground contact forces are also calculated and they drive and steer the car. Documentation links for vehicle controller in Bullet and PhysX. Settings below for Bullet.

Wheel Settings

wheelRadius : radi

Radius of the wheel. Should fit the render mesh of the wheel.

connectionPointCS0

Start of raycast relative to car body. The point where the suspension connects to the chassis.

wheelDirectionCS0

Direction of raycast relative to car body. Straight down is a good start. The length of the ray is m_suspensionRestLength1 + wheelRadius.

wheelAxleCS

Axis direction of wheel relative to car body. Selects what the zero direction is for wheel steering.

Suspension Settings

suspensionRestLength : restl

Whats the default position of the wheel if not in contact with ground. The maximum length of the suspension in metres. It's wheel center will then be at connectionPointCS0 + wheelDirectionCS0 * m_suspensionRestLength1.

m_maxSuspensionTravelCm : susp

The maximum distance the suspension can be compressed in centimeters.

m_suspensionStiffness : stiff

The stiffness constant for the suspension. How much force the suspension give on the chassi when the wheel is not in the default position. 10 - offroad buggy, 50 - sports car, 200 - F1 car.

currentLength = ray.distance - wheel radius

suspensionForce = stiffness * (restLength – currentLength) + damping * (previousLength – currentLength) / deltaTime

m_wheelsDampingCompression : comp

Damping coefficient when suspension is compressing. Set to k * 2.0 * sqrt(suspensionStiffness). k = 0.0 undamped and boyncy, k = 1 critical damping, k = 0.1 to 0.3 good values.

m_wheelsDampingRelaxation : relx

Damping coefficient when suspension is extending. This should be slightly higher then m_wheelsDampingCompression. k = 0.2 - 0.5.

m_frictionSlip : slip

Coefficient of friction between tire and the ground. 0.8 for real cars and higher for better handling.

m_rollInfluence : roll

0.0 = no roll, 1.0 = physical behaviour. High frictionslip then need to reduce this.

m_maxSuspensionForce : forc

Rigid Body

Mass

Mass of the vehicle. Typical values are 1500kg for a car.

Center Of Mass

The center of mass should be put in the lower part of the car to make it more stable and lower the risk of it flipping over.

Wheel Parameters

EngineForce

Positive if wheel drive forward and negative is back.

Brake

SteeringValue

The forward direction of the wheel with respect to it's default forward from wheelAxleCS.