← ⚡ Physics & Mechanics
DRIFT!
NITRO 🚀
Controls
W/↑ — gas    S/↓ — brake
A/D — steering
Space — handbrake / drift
Shift — nitro boost
C — camera mode
V — day / night
O — SSAO on/off
R — reset
0
KM/H
N
RPM
NITRO
Odometer: 0.00 km
📷 Follow
WASD · Space=drift · Shift=nitro · C=camera · V=day/night · O=SSAO · R=reset

🚗 Car Physics — 3D Driving Simulation

A real-time 3D car physics simulation modelling engine torque, tyre friction, aerodynamic drag, and weight transfer. Every corner tests the balance between grip and momentum.

🔬 What It Demonstrates

The simulation models drivetrain torque, tyre slip using the Pacejka magic formula, aerodynamic drag, weight transfer under acceleration and braking, and suspension dynamics.

🎮 How to Use

Use arrow keys (or on-screen controls) to throttle, brake, and steer. Try sharp corners at high speed to experience understeer. Brake before a turn to shift weight forward and improve grip.

💡 Did You Know?

Formula 1 cars generate so much aerodynamic downforce that they could theoretically drive upside-down in a tunnel at speeds above ~130 km/h. The tyres would still have grip — but the g-forces would be unsurvivable.

About the Car Physics Simulation

This real-time 3D demo models how a car accelerates, brakes, steers and drifts while riding over procedurally generated rough terrain. It pairs a kinematic bicycle steering model with a longitudinal force balance: net acceleration is drive force minus aerodynamic drag and rolling friction, divided by mass. Lateral velocity, an independent spring-damper at each wheel and weight transfer add the feel of a real vehicle, all integrated frame by frame using the per-frame time step dt.

You drive with W/S for gas and brake, A/D to steer, Space for the handbrake that breaks rear grip into a drift, and Shift for a finite nitro boost that lifts the top speed. C cycles four cameras, V toggles day and night lighting, O switches SSAO ambient occlusion, and R resets. These same ideas underpin racing games, driver-training rigs and the traction and stability-control electronics that keep real cars planted on slippery roads.

Frequently Asked Questions

What does this simulation actually show?

It shows a drivable 3D car obeying simplified vehicle dynamics: acceleration, braking, speed-dependent steering, cornering grip, drifting and suspension travel over a bumpy landscape. The dashboard reports speed in km/h, a synthetic gear, engine RPM, the remaining nitro charge and an odometer, so you can watch the physics respond to your inputs in real time.

How does the steering model work?

It uses a kinematic bicycle model, where the four wheels are reduced to one front and one rear wheel. The car heading updates roughly as theta plus (v divided by L) times the sine of the steering angle, times dt, with v the speed and L the wheelbase. Steering authority is also speed-sensitive, so the turn rate behaves more naturally as you slow down or speed up.

What is the key equation behind acceleration?

Longitudinal motion follows Newton's second law, F equals m times a. The simulation computes acceleration as drive force minus aerodynamic drag and rolling friction, all divided by mass. Constants in the code set the limits: top speed around 22 units, acceleration 12, braking force 20 and friction 3.8, with a nitro boost adding about 9 to the top speed while it lasts.

How does drifting happen?

The car tracks a separate lateral velocity that builds up when you corner hard. Normally a high lateral grip constant of about 13 scrubs that sideways motion away quickly. Pressing Space applies the handbrake, which drops the grip to roughly 1.8, so the rear end slides out and the car drifts until grip recovers.

What does the nitro boost do?

Holding Shift drains a finite nitro reserve and temporarily raises the maximum speed by about nine units, emitting blue flame particles from the exhaust. The reserve depletes while boosting and slowly regenerates when you release the key, so you must manage it rather than rely on it continuously.

What are all the controls?

W or the up arrow accelerates, S or down brakes and reverses, and A and D steer left and right. Space is the handbrake and drift trigger, Shift is the nitro boost, C cycles between the follow, low, hood and bird's-eye cameras, V toggles day and night, O turns SSAO shading on or off, and R resets the car to the start.

How does the suspension behave over rough ground?

Each of the four wheels runs an independent spring-damper that samples the terrain height beneath it and pushes the wheel up or down. This lets the body pitch and roll, compress over bumps and rebound afterwards, giving the visible squat under acceleration and dive under braking rather than a rigid, flat ride.

Is this physically accurate?

It is a believable arcade-style approximation, not an engineering-grade model. It captures the right qualitative behaviour, such as drag-limited top speed, grip loss in drifts and suspension travel, but it omits detailed tyre slip curves, real gear ratios and full chassis dynamics. The numbers are tuned for fun and responsiveness rather than matching a specific vehicle.

Why does the car grip better when slightly sliding?

Real tyres reach peak grip not when rolling perfectly but when slipping a few percent, the slip-ratio sweet spot. That is why anti-lock brakes pulse the brakes: a wheel that is barely sliding stops a car faster than one that is fully locked. The drift mechanic here is a simplified nod to that grip-versus-slip relationship.

Where are these physics used in the real world?

The same force-balance and grip ideas drive racing and driving video games, professional driver-training and motorsport simulators, and the control logic in modern cars. Anti-lock braking, traction control and electronic stability programs all rely on continuously estimating wheel slip and lateral motion, exactly the quantities this simulation tracks.