Skip to content

thetruth2003/engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš— Realistic Vehicle & Powertrain Simulation (Unity)

High-fidelity vehicle dynamics & powertrain simulation built for realism, modularity, and AAA-grade extensibility.
Data-driven pipeline (ScriptableObjects), deterministic update order, rich telemetry, and plug-and-play subsystems: engine, clutch, gearbox, differentials, tires, suspension, aero, ABS/TCS/ESC.

Target: 90โ€“120 FPS @ fixed ฮ”t = 0.005โ€“0.01 s (Unity 2022.3 LTS)


๐Ÿ“‹ Contents


---

๐ŸŽฏ Goals & Principles

  • Realism first: physically-meaningful units (Nยทm, kg, m/s, ยฐC).
  • Modular composition: subsystems behind clear interfaces.
  • Data-driven: all tuning via ScriptableObjects (no code edits).
  • Deterministic: stable fixed-timestep order, repeatable replays.
  • Tooling mindset: HUD telemetry, CSV logger, replay/ghost, validators.

๐Ÿงฑ System Architecture

[VehicleController]
โ”œโ”€ Powertrain
โ”‚ โ”œโ”€ EngineModel (torque curve, throttle, inertia, limiter, stall)
โ”‚ โ”œโ”€ ClutchModel (manual/auto, slip, wear, heat)
โ”‚ โ”œโ”€ Gearbox (H-pattern / sequential, ratios, synchro, shift cut)
โ”‚ โ”œโ”€ Differentials (open / clutch LSD / torsen)
โ”‚ โ””โ”€ Driveline (FWD / RWD / AWD torque split)
โ”œโ”€ Chassis
โ”‚ โ”œโ”€ Suspension (springs, bump/rebound, ARB, motion ratio)
โ”‚ โ”œโ”€ Tires (combined slip, load/camber sensitivity)
โ”‚ โ”œโ”€ Steering (Ackermann, ratio, compliance)
โ”‚ โ””โ”€ Brakes (bias, fade model, ABS)
โ”œโ”€ Control Aids
โ”‚ โ”œโ”€ ABS / TCS / ESC (PID-based, per-wheel)
โ”‚ โ””โ”€ Rev-Match / Auto-Blip / Launch Control / Hill-Hold
โ”œโ”€ Aero & Environment
โ”‚ โ”œโ”€ Drag (CdA) / Downforce (per-axle maps, speedยฒ)
โ”‚ โ””โ”€ Surface ฮผ scaling (dry/wet/ice), aquaplaning threshold
โ”œโ”€ Thermal & Damage
โ”‚ โ”œโ”€ Engine coolant/oil temps, heat soak
โ”‚ โ””โ”€ Clutch/brake fade, tire core/surface temp loops
โ””โ”€ Telemetry & Tools
โ”œโ”€ HUD overlays, CSV logger, replay/ghost
โ””โ”€ Asset validators & tuning presets


๐ŸŒŸ Key Features

Powertrain

  • EngineModel: RPM-based torque curve (lookup + spline), engine inertia, throttle dynamics, idle controller, soft/hard limiter, stall.
  • ClutchModel: clamp force, friction ฮผ, slip heat & wear, manual & auto-clutch strategies, bite-point calibration.
  • Gearbox: H-pattern & sequential; ratios/final drive; synchro timing, shift latency, ignition/throttle cut under load.
  • Differentials: open, clutch-type LSD (preload, accel/decel ramps), torsen (bias ratio).
  • Driveline: FWD / RWD / AWD; static or dynamic torque split; viscous coupling.

Vehicle Dynamics

  • Suspension: per-corner springs, bump/rebound damping, motion ratios, anti-roll bars, travel limits, bump stops.
  • Tires: combined slip (long+lat), load & camber sensitivity, temperature-dependent ฮผ; supports empirical or Pacejka-style curves.
  • Steering: Ackermann geometry, rack ratio, compliance, return torque.
  • Brakes: torque curves, thermal fade and recovery, front/rear bias, ABS (per-wheel slip targets).

Control Aids

  • ABS/TCS/ESC (PID) with profiles (Wet/Dry/Sport/Off).
  • Rev-Match / Auto-Blip, Launch Control, Hill-Hold (optional).

Aerodynamics & Environment

  • Drag (CdA) & downforce (per-axle; speedยฒ; ride-height maps).
  • Weather: friction scaling by surface; standing water threshold for aquaplaning modeling.

Thermal & Damage

  • Engine coolant & oil loops; heat soak after shutdown.
  • Clutch thermal overload โ†’ glazing โ†’ reduced ฮผ/holding torque.
  • Brake temperature โ†’ fade curves; tire core/surface temp โ†’ ฮผ change.

Tooling

  • Telemetry HUD: RPM/gear, wheel slips, tire loads & temps, brake temps, aero forces, aids activity.
  • CSV Logger: frame-accurate channels for external analysis.
  • Replay & Ghost: deterministic input/state capture & playback.
  • Validators: ratios, redline/limiter, axle loads, mass budget.

๐Ÿ—‚๏ธ Data-Driven Pipeline (ScriptableObjects)

Asset Purpose
EngineData Torque curve, inertia, throttle, limiter
GearboxData Ratios, final drive, synchro & shift timings
ClutchData Clamp force, friction ฮผ, bite-point, auto-clutch
DiffData Type, preload, ramp/bias
SuspensionData Spring, damper, ARB, motion ratio
TireCompoundData ฮผ vs slip/load/temp/camber curves
BrakeData Brake torque, cooling, fade model
AeroData CdA, downforce maps, ride-height dependency
AssistProfiles ABS/TCS/ESC PID gains & slip targets
VehicleConfig Mass, CoG, wheelbase, weight distribution

Designers tune without code; editor hot-reload supported.


โš™๏ธ Update Order & Integration

  • Fixed timestep simulation (Time.fixedDeltaTime = 0.005โ€“0.01 s).
  • Order: Input โ†’ Powertrain โ†’ Tires/Chassis โ†’ Aids โ†’ Aero โ†’ Thermal โ†’ Telemetry.
  • Physics in FixedUpdate; visuals in Update (interpolation).
  • Optional sub-stepping for high-slip events (launch, ABS).

๐Ÿงช Tuning & Validation Workflow

  1. Baseline: mass, CoG, wheelbase โ†’ verify static axle loads.
  2. Powertrain: import dyno curve; set redline/limiter, engine inertia, idle target.
  3. Gearing: choose ratios for target 0-100/Vmax; validate RPM drop per shift.
  4. Suspension: front/rear ride frequencies; ARB balance for under/oversteer.
  5. Tires: compound selection; calibrate ฮผ vs temp & load to reference behavior.
  6. Brakes: bias & torque; ABS slip targets; long-run fade test.
  7. Aero: CdA for top speed; downforce & balance for stability.
  8. Aids: tune profiles (Wet/Dry/Sport); compare lap deltas.
  9. Validation: run asset validators; export CSV telemetry for review.

๐Ÿ“Š Telemetry Channels (Sample)

  • Kinematics: speed, accel, yaw rate, slip angles, ride heights, suspension travel.
  • Tires: Fx/Fy/Fz per wheel, slip ratio/angle, ฮผ used, surface/core temps.
  • Powertrain: engine/input/output RPM, gear index, clutch slip, torque flows.
  • Brakes: pressure, temp, fade factor; ABS state per wheel.
  • Aero: drag/downforce per axle; aero balance % front.
  • Aids: ABS/TCS/ESC enable flags, controller outputs.
  • Environment: surface ฮผ, water depth (if enabled), air density.

๐Ÿงฉ Extensibility Points (Interfaces)

  • ITireModel: swap empirical/Pacejka implementations.
  • IDiffModel: add active center diff or e-diff/torque vectoring.
  • IAeroMap: speed & ride-height-dependent downforce models.
  • IController: custom aids (rally ABS, drift mode, yaw control).
  • IRecorder: pluggable logging/replay backends.

๐ŸŽฎ Input & FFB

  • Unity Input System: wheel/pedals/shifter bindings.
  • Clutch axis with bite-point curve; analog handbrake.
  • FFB hooks (aligning torque, load-based cues) exposed for wheel SDKs.

๐Ÿงฐ Demo Content

  • RWD Sports: manual H-pattern + clutch LSD.
  • AWD Street: sequential + active torque split.
  • FWD Hot-Hatch: open diff tuned with ABS/TCS for torque steer.

Each demo includes tuned ScriptableObjects, telemetry HUD, and lap replay.


๐Ÿš€ Quick Start

  1. Install: Import the package into Unity 2022.3 LTS project.
  2. Create assets: EngineData, GearboxData, ClutchData, DiffData, SuspensionData (4ร—), TireCompoundData, BrakeData, AeroData, AssistProfiles, VehicleConfig.
  3. Setup scene:
    • Add VehicleController to a car prefab with 4 wheel objects.
    • Assign data assets on VehicleController inspector.
    • Ensure Time.fixedDeltaTime is 0.005โ€“0.01; Physics set to Discrete.
  4. Telemetry: Enable HUD & CSV Logger in VehicleController โ†’ Tools.
  5. Drive: Play the scene; use profiles (Wet/Dry/Sport/Off) to verify aids.

๐Ÿ“ฆ Requirements

  • Unity 2022.3 LTS
  • Physics: Discrete solver, fixed ฮ”t 0.005โ€“0.01 s
  • Scripting: .NET Standard 2.1

๐Ÿ”’ Quality & Testing

  • Unit tests: torque flow, ratio math, limiter & stall behavior.
  • Scenario tests: ฮผ-split ABS braking, launch control, long-run brake fade.
  • Performance budgets per subsystem; CPU/GPU profiling guides included.
  • Deterministic replay verification across platforms/builds.

๐Ÿ“ Folder Structure

/Runtime
/Core
/Powertrain (Engine, Clutch, Gearbox, Diff, Driveline)
/Chassis (Suspension, Tires, Steering, Brakes)
/Aero
/Aids (ABS, TCS, ESC, Controllers)
/Thermal
/Telemetry (HUD, Logger, Replay, Validators)
/Data (ScriptableObjects)
/Demo (Prefabs, Scenes, Presets)
/Editor
(Inspectors, Validators, Debug Windows)
/Tests
(Unit + Scenario)


๐Ÿ—บ๏ธ Roadmap

  • Active center diff & e-diff torque vectoring
  • Wet surface film depth โ†’ aquaplaning lateral model
  • Nonlinear bushing compliance & chassis flex approximation
  • Advanced FFB profiles per vehicle archetype

โœ… What This Demonstrates (For Recruiters)

  • End-to-end realistic, physically-grounded vehicle systems.
  • Modular, interface-driven architecture ready for feature swaps.
  • Data-driven workflow enabling fast designer iteration.
  • Production-minded tooling: telemetry, replay, validators, tests.
  • Performance awareness (fixed ฮ”t, sub-stepping, profiling, budgets).

๐Ÿ“„ License

Copyright ยฉ 2025. All rights reserved.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors