Vehicle Physics & Torque Mechanism

This page explains how the handling and physics systems work in the mechanic script. The system follows a 3-layer pipeline from static configuration to real-time torque application with electronic assists.

1. Data Pipeline

The system processes data in the following sequence:

  1. Static Configuration: Data defined in shared/handling/vehicle_config.lua (Mass, Drag, Power, Torque Curve).

  2. Physics Kernel:

    • Adjusts base handling fields (Mass, Drag, Top Speed) when a player enters a configured vehicle.

    • Calculates a physicsTorque multiplier based on the model's Torque Curve and Power-to-Weight Ratio.

    • Stores calculations in a state bag for low-latency synchronization.

  3. Application & Assists:

    • Listens for physics updates.

    • Applies Traction Control (TCS) and Electronic Stability Control (ESC) logic to the current torque value.

    • Applies the final multiplier to the game engine via native torque injection.


2. Torque Calculation

The torque multiplier is derived using the following logic:

multiplier = (CurrentTorque / 500.0) * (Power * 5.0) * (PTW / 0.00015) * InductionGain
  • Torque Curve: RPM values are mapped to specific torque outputs. The script uses linear interpolation between defined points.

  • PTW (Power-to-Weight): Scales engine performance relative to the vehicle's curb weight.

  • Induction Gain: Additional multiplier applied if the vehicle is equipped with a Turbo or Supercharger.


3. Electronic Assists (TCS & ESC)

Traction Control System (TCS)

Monitors wheel slip ratio. If the wheels spin faster than the vehicle's ground speed beyond a specific threshold (default 15%), the script cuts engine torque to regain grip.

Electronic Stability Control (ESC)

Compares the vehicle's actual Yaw Rate (rotation) against the Intended Direction (derived from speed and steering angle).

  • Oversteer Correction: If the car spins more than intended, a corrective lateral force is applied to the rear axle.

  • Power Reduction: Engine output is slightly throttled during the correction phase to improve stability.


4. Handling Overrides

The configuration can override standard GTA handling values:

  • Mass: Vehicle curb weight.

  • Drag: Aerodynamic drag (affects high-speed acceleration).

  • Roll Center: Mapped from bodyRollAmmount to affect stability during turns.

  • Top Speed: Overrides the maximum flat velocity.


5. Tire Configuration (tire_config.lua)

The tire system uses profiles to dynamicially adjust traction and thermal properties. Each profile defines how the vehicle interacts with the ground surface.

Tire Profiles

Common profiles include Street, Sport, Race, Slick, and Drift. Each affects:

  • Peak Traction (G): Mapped to fTractionCurveMax. Defines the absolute grip limit.

  • Lateral Curve Angle: Mapped to fTractionCurveLateral. Affects how "snappy" or "vague" the car feels when sliding.

  • Thermal Model: Defines base temperatures, grip-to-heat curves, and wear rates.

  • Friction Scales: Longitudinal and lateral friction multipliers.

Dynamic Physics Application

When tires are installed, their advanced settings are stored in the dynamic:tyre:config state bag. This allows other physics modules to process heat-based grip loss and wear in real-time.

[!IMPORTANT] To prevent conflicts, static configuration overrides are automatically disabled if the Handling Editor is currently active on the vehicle.

Last updated