Building an Off-Road Sim From the Physics Up

Building an Off-Road Sim From the Physics Up

Inputread onceUniversalCarowns the physicsWheelssuspension state onlyForcesAddForceAtPosition

I spend enough time on real trails that the off-road games always bother me in the same place: the physics. So my current side project is an off-road simulation in Unity with fully custom vehicle physics. No built-in WheelCollider, no shortcuts. Raycast suspension where every parameter is mine to tune: spring rate, damping, ride height, travel, grip. The long-term goal is proper mud and terrain deformation, but the vehicle foundation has to be right first.

The first architecture was the obvious one and it was wrong. Each wheel had its own script reading input and applying drive forces, which meant four scripts fighting over one chassis. Debugging was miserable. The rewrite moved everything into a single controller that reads input once, owns steering and drive, and loops through the wheels, which only report suspension state and contact. The lesson carries outside game dev: a vehicle is one physical system, and the moment you let the parts make their own decisions you get four opinions instead of one truth. Same reason a car has one ECU and not one per cylinder.

The suspension itself uses sphere casts against a dedicated ground layer, with spring and damper forces applied at each wheel’s position on the chassis body. Each wheel tracks its previous compression so damping works from real spring velocity instead of guesses.

Best bug so far: on the first run of the new architecture, the truck launched into orbit the instant I hit play. Chased scripts, spring constants, force limits, and layer masks before finding the indicator that mattered: raising the chassis stopped the launch. The suspension was starting fully compressed, so frame one contained a spring at maximum stored energy with nowhere to go but up. Every discipline has its version of this: the fault appears at startup because the initial conditions were wrong, not because the running system is broken.

It drives, it’s stable, and there’s a long list ahead: tire friction, braking, slip, weight transfer, then the terrain work. This one connects the two halves of the garage directly, because twenty years of real axle swaps and trail miles is exactly the reference data a simulation needs.