2D Vehicles
Recorded: Oct. 10, 2026, 7:01 p.m.
| Original | Summarized |
2D Vehicle Physics Prototype · Pat Kerr pat kerr Home A project history · 1996–2026 One weekend in late August 1996, I wrote a 2D physics simulation which later became It began as a little wireframe demo written in GFA BASIC on my Atari ST home computer I have The 1996 idea, recreated in Motion Lab. Instructions In addition to the default "Car" mode (1), you can also select the technically simpler Collision barriers around the sides of the playfield can be toggled by clicking or Camera controls are provided by "Z" and "X": "Z" toggles what is called the camera's *(in an entirely non-copyright and non-trademark infringing way, of course) [VOLUNTARY DISCLAIMER: This work is wholly independent of, and in no way affiliated How it works The prototype combined a general-purpose 2D rigid body with a deliberately simple The original simulation started with something like the "Brick", and I then added some At the core of the system is a simple classical 2D rigid body dynamics simulation. On top of that core, I then added a "novel" vehicle simulation layer, based on a These diagrams describe the current JavaScript recreation. The browser interface The overall flow, from the page and controls to simulation and drawing. One body, three behaviours A vehicle combines a rigid body with a shell that describes its display shape and How the vehicle coordinator combines shape, behaviour and body state. Forces can move and turn the body The rigid body tracks position and velocity alongside angle and angular velocity. A Barriers use that same point velocity. When a shape crosses an edge, the simulation The shared physics core and the steps used to resolve barrier contacts. The deliberately approximate tyres For each tyre, the Car measures the velocity at its position and resolves it into two Those resistance forces are proportional to velocity, without a force cap. That is a The force models, including wheel velocity components and handbrake behaviour. Putting the pieces together The Vehicle coordinator asks the selected dynamics object to apply its forces, then A closer look at mode installation, simulation updates and contact geometry. © Site v |
The prototype developed by Pat Kerr originated as a 2D physics simulation created in 1996, which later served as the foundational system for vehicle mechanics in the game Grand Theft Auto. The simulation evolved from an initial wireframe demonstration written in GFA BASIC on an Atari ST home computer, eventually being ported to C for use in the actual game, and is now recreated in JavaScript for modern presentation. The core of the simulation employs a two-layered approach combining a general-purpose 2D rigid body dynamics system with a deliberately simple model for a vehicle. The system’s foundation is a classical 2D rigid body simulation that accurately tracks position, velocity, angle, and angular velocity. This approach was chosen because it handles rotational components more coherently than earlier methods that relied on basic point physics, which often required "hacks" for rotational effects. This rigid body dynamics allows forces applied through the center to change linear motion and torques to induce rotation, which are then integrated to update the body’s state. Upon this core, the prototype introduced a novel simulation layer based on an approximate model of tire behavior. This layer was conceptually added on top of the rigid body mechanics and involved modeling resistive forces related to rolling and sideways motion. While acknowledging that this model was a semi-educated approximation rather than a strictly physically accurate account of tire friction or slip, it was deemed sufficient for the prototype’s purposes. This system is layered with three distinct behavioral modes: Brick, Ship, and Car, which each interact with the same underlying physics core through different force application methods. Switching between these modes alters the shell and behavior components while preserving the existing position and motion of the rigid body. The interaction between the various components is managed by a vehicle coordinator. This coordinator is responsible for synthesizing the vehicle's shape, its dynamic behavior, and its overall body state. It mediates how external inputs translate into motion by instructing the selected dynamics object to apply forces and subsequently advancing the rigid body. Furthermore, the system manages collision detection, where barriers interact with the body using the point velocities of the body. A simple barrier solver is employed, which handles contact impulses by moving intersecting shapes back to their valid positions and applying impulse forces upon collision, facilitating rotational changes in the body resulting from off-center impacts. Specific vehicle behaviors are distinguished by how they utilize the physics core. The Brick mode responds to pointer drag, the Ship mode generates thrust from an attachment point, and the Car mode incorporates engine forces and steering. For the Car mode specifically, the simulation incorporates the approximate tire model where velocity at the wheel positions is resolved into components along the wheel's heading and across it. This process applies damping resistance proportional to velocity, simulating rolling and resisting sideways movement without requiring complex friction modeling. Steering actions affect the heading of the front wheels, thereby influencing the overall rotational dynamics of the vehicle. The system ensures that when collisions occur, the contact geometry is resolved by considering the midpoint of contacting points to avoid introducing artificial spin, ensuring a more physically consistent outcome. |