Custom Car Physics

Update: May 2025

After months of research, poring over source code, debugging, testing different scenarios, and chatting with ChatGPT, Grok, and DeepSeek, I’ve finally reached a milestone I’m excited to share. In the video below, you’ll see the car navigating rough terrain and off-roading. Nothing too special—until you realize the simulation is running at only 15 FPS, with no additional physics sub-stepping.

The simulation uses a custom implementation of Heun’s algorithm with multiple iterations, enabling it to run smoothly even at such a low frame rate. I call this technique “integrating over the frame.” Here’s how it works:Forces from the tires and suspension are calculated in the first iteration. Then, the car’s state is predicted a small step forward in time (DeltaTime / IterationsCount), and all forces are recalculated. This process repeats several times per frame. The result is a remarkably smooth and stable simulation, suppressing rapid fluctuations in wheel angular velocity, slip ratios, suspension damping, etc.

Near-zero forces

To address the issue of slip ratios switching signs at very low speeds (below 1 m/s), I used a different tire friction model—Coulomb friction. Unlike traditional slip-based models, the Coulomb approach ensures stable and physically accurate behavior when the vehicle is nearly stationary. This allows the car to come to a complete stop on an incline without drifting or jittering, achieving a true equilibrium state both longitudinally and laterally. The three videos below compare three scenarios: The far left with only Pacejka friction model being enabled and Heun disabled (only 1 Iteration), the middle video being Pacejka with 4 Heun iterations, and right most being Coulomb friction enabled at low speeds with 2 Heun iterations.

ABS Braking

ABS braking is also added to the car, with a mechanism that adjusts the strength of brake based on wheel slip. When ABS braking is turned off, the stopping distance increases, the wheels lock and the car loses the ability to steer when braking. The two videos below show the comparison of ABS enabled and disabled.

Initial Update: January 2025

This is my research about physics in video games! Instead of using PhysX or the Chaos vehicle system provided by Unreal, I built a car from scratch, relying on ray-cast-based wheels and accurate force calculations.

Unlike Chaos or PhysX, which derive wheel angular speed from ground speed and introduce slip ambiguously, my model computes the wheel’s angular velocity independently, without tying it strictly to ground speed or engine RPM. To model friction, I implemented the Pacejka magic formula, ensuring precise friction coefficients.

Additionally, the model incorporates combined slip by blending longitudinal and lateral coefficients with a scale factor, effectively preventing unrealistic behavior. For performance reasons, I developed this in Unreal Engine 4. As shown, it is a semi rear-wheel-drive car with an 80% rear and 20% front power split. The car enters drifting when high power is delivered to the wheels. The small amount of power given to the front wheels keeps the car in motion rather than introducing high angular velocity around the center, which would result in a donut. This behavior occurs with the traction control system (TCS) disabled, but with TCS enabled, the car becomes much less slippery and easier to control. Physics sub stepping is used to simulate a deterministic behavior.