AA Vehicle Controller
A production-ready, physics-based vehicle simulation system for Unity. Features realistic driving mechanics, advanced AI with A* GPS pathfinding, multi-layer audio, damage deformation, mobile controls, and a one-click Vehicle Creator Wizard.
⚙ Requirements
Minimum setup needed to use this package.
Unity Version
Unity 2022.3 LTS or newer. Supports Unity 6+.
Render Pipeline
Works with Built-in, URP, and HDRP. Emission intensity adapts automatically.
Input System
Supports both Legacy Input Manager and New Input System. Auto-detects at runtime.
TextMeshPro
Required for Dashboard UI. Included in Unity by default.
⚡ Quick Start Guide
Get a driveable vehicle in under 2 minutes.
Method 1: Vehicle Creator Wizard (Recommended)
- Go to
Tools → Abyssal Ababeel → Vehicle Creator Wizard - Drag your vehicle 3D model into the Vehicle Model slot
- Assign the 4 wheel meshes (FL, FR, RL, RR)
- Select a preset (Sports, Sedan, SUV, Racing, etc.)
- Enable desired systems: Audio, AI, Nitro, Damage, Lights, etc.
- Click "Create Vehicle" — done!
Method 2: Manual Setup
- Add a
Rigidbodyto your vehicle root object - Add 4 child
WheelCollidercomponents at each wheel position - Add the
VehicleControllercomponent (auto-adds WheelManager, SoundManager, VehicleInput) - Assign wheel colliders in the
WheelManager - Configure the
VehiclePresetin the inspector - Add a
VehicleCamerato your Main Camera - Press Play!
🛠 Architecture Overview
How the package components connect together.
Namespace Structure
AbyssalAbabeel.VehicleController // Core (VehicleController, VehicleInput, VehiclePreset, Events)
AbyssalAbabeel.VehicleController.Audio // SoundManager, VehicleAudio
AbyssalAbabeel.VehicleController.AI // AIVehicleController, AIForesight
AbyssalAbabeel.VehicleController.Systems // Nitro, Damage, Lighting, SkidMark, TireSmoke
AbyssalAbabeel.VehicleController.Camera // VehicleCamera
AbyssalAbabeel.VehicleController.UI // VehicleDashboard
AbyssalAbabeel.VehicleController.Mobile // MobileInputHandler, SteeringWheel/Drag/Buttons
Pathfinder.Runtime // PathGrid, AStarSolver, PathNode, RuntimePathfinder
🚗 Vehicle Controller
Core physics and driving simulation component. Attach to the vehicle root GameObject.
Script: Runtime/Core/VehicleController.cs • Requires: Rigidbody, WheelManager, SoundManager, VehicleInput
Engine Settings
| Property | Type | Default | Description |
|---|---|---|---|
| maxRPM | float | 5000 | Maximum engine RPM before rev limiter kicks in. |
| minRPM | float | 900 | Minimum RPM the engine will hold (prevents stalling). |
| idleRPM | float | 800 | RPM when stationary with no throttle input. |
| enginePowerCurve | AnimationCurve | 100→500 | Torque output over RPM range (X: 0–1 normalized RPM, Y: Nm). |
| engineSmoothTime | float | 0.2 | Smoothing for RPM changes (lower = snappier response). |
Transmission
| Property | Type | Default | Description |
|---|---|---|---|
| driveType | enum | AWD | FrontWheelDrive, RearWheelDrive, or AllWheelDrive. |
| maxSpeedKPH | float | 150 | Top speed in kilometers per hour. |
| numberOfGears | int | 5 | Number of forward gears (ratios auto-generated if empty). |
| finalDrive | float | 2.5 | Final drive ratio — higher = more acceleration, lower top speed. |
| reverseSpeedKPH | float | 40 | Maximum reverse speed. |
| isAutomatic | bool | true | Auto gear shifting. Set false for manual (use Q/E keys). |
Physics
| Property | Type | Default | Description |
|---|---|---|---|
| vehicleWeight | float | 1900 | Vehicle mass in kg. Applied to Rigidbody. |
| torqueMultiplier | float | 2 | Global torque scale. Increase for more power. |
| downForceValue | float | 12 | Downforce applied at speed for grip (N per m/s). |
| dragAmount | float | 0.015 | Aerodynamic drag coefficient. |
| brakeMultiplier | float | 1 | Scales brake force for both foot brake AND handbrake. Range: 0.5–5. |
| maxSteeringAngle | float | 38 | Maximum wheel steering angle in degrees. |
| centerOfMassTransform | Transform | null | Custom center of mass position. Critical for handling balance. |
Drift System
| Property | Type | Default | Description |
|---|---|---|---|
| enableDrift | bool | true | Enable drift mechanics on handbrake. |
| driftIntensity | float | 0 | How aggressively the rear breaks loose (0 = mild, 1+ = extreme). |
| driftStiffnessReduction | float | 6 | Rear tire sideways stiffness reduction during drift. |
Launch Control
| Property | Type | Default | Description |
|---|---|---|---|
| enableLaunchControl | bool | false | Enable launch control system. |
| launchControlRPM | float | 4500 | RPM limit while arming (hold handbrake + throttle). |
| launchBoostMultiplier | float | 1.3 | Torque boost on launch release. |
Read-Only Properties
| Property | Type | Description |
|---|---|---|
| engineRPM | float | Current engine RPM. |
| KPH | float | Current speed in km/h (negative when reversing). |
| RPMPercent | float | Normalized RPM (0–1). Useful for UI gauges. |
| EngineLoad | float | Current engine load (0–1). Used by audio systems. |
| currentGear | int | Current gear number (1–N). |
| isReversing | bool | True when vehicle is in reverse gear. |
| engineRunning | bool | True when engine is on. |
🎮 Vehicle Input
Unified input handler supporting Legacy, New Input System, and Mobile modes.
Script: Runtime/Core/VehicleInput.cs • Auto-added with VehicleController
Input Modes
| Mode | Description | Setup |
|---|---|---|
| LegacyInput | Unity's classic Input Manager (GetAxis, GetKey). | Works out of the box. Configure axis names in inspector. |
| NewInputSystem | Unity's new Input System package. | Assign InputActionAsset. Create "Vehicle" action map with: Steer, Throttle, Handbrake actions. |
| Mobile | Touch-based on-screen controls. | Input handled by MobileInputHandler component. Add UI buttons. |
Legacy Input Key Bindings
| Property | Default Key | Description |
|---|---|---|
| horizontalAxis | "Horizontal" | Steering (A/D or Arrow keys). |
| verticalAxis | "Vertical" | Throttle/Brake (W/S or Arrow keys). |
| handbrakeKey | Space | Handbrake / Drift trigger. |
| shiftUpKey | E | Manual shift up. |
| shiftDownKey | Q | Manual shift down. |
| engineToggleKey | F | Start/Stop engine. |
| nitroKey | Left Shift | Activate nitro boost. |
| cameraSwitchKey | Tab | Cycle camera modes. |
isAIControlled = true, all human input is skipped. The AIVehicleController writes directly to horizontal, vertical, and handbrake fields.📦 Vehicle Presets
ScriptableObject-based vehicle configuration. Save and share vehicle setups as assets.
Script: Runtime/Core/VehiclePresetAsset.cs • Menu: Abyssal Ababeel → Vehicle Preset
Built-in Factory Presets
| Preset | Top Speed | Max RPM | Weight | Drive | Drift | Launch Control |
|---|---|---|---|---|---|---|
| Sports | 260 km/h | 8000 | 1400 kg | RWD | Yes (1.2) | Yes |
| Sedan | 200 km/h | 6500 | 1600 kg | FWD | No | No |
| SUV | 180 km/h | 6000 | 2200 kg | AWD | No | No |
| Racing | 320 km/h | 9000 | 1100 kg | RWD | Yes (0.8) | Yes (1.5x) |
| Truck | 140 km/h | 4500 | 3500 kg | RWD | No | No |
| Offroad | 160 km/h | 5500 | 2000 kg | AWD | No | No |
| Van | 160 km/h | 5000 | 2800 kg | FWD | No | No |
Usage
// Create preset from code
var preset = VehiclePresetAsset.CreateSportsPreset();
// Apply preset to vehicle at runtime
vehicleController.activePreset = preset.ToRuntimePreset();
// Save current settings to preset asset
preset.FromRuntimePreset(vehicleController.activePreset);
🔔 Vehicle Events
UnityEvent-based callbacks for game logic integration.
Script: Runtime/Core/VehicleEvents.cs
| Event | Type | Fires When |
|---|---|---|
| onEngineStarted | UnityEvent | Engine successfully starts. |
| onEngineStopped | UnityEvent | Engine is turned off. |
| onGearChanged | UnityEvent<int,int> | Gear changes. Args: (oldGear, newGear). |
| onShiftUp / onShiftDown | UnityEvent | Gear shifts up or down. |
| onDriftStarted / onDriftEnded | UnityEvent | Vehicle enters/exits drift state. |
| onHandbrakeChanged | UnityEvent<bool> | Handbrake state toggles. |
| onSpeedChanged | UnityEvent<float> | Speed changes (KPH value). |
| onNitroActivated / Deactivated | UnityEvent | Nitro boost starts/stops. |
| onCollision | UnityEvent<float> | Vehicle collides. Arg: impact force. |
| onReverseEngaged / Disengaged | UnityEvent | Reverse gear toggled. |
| onAllWheelsGrounded / onAirborne | UnityEvent | Grounding state changes. |
🎵 Sound Manager
Advanced positional audio with 11 independent sound components, interior/exterior switching, and per-component volume control.
Script: Runtime/Audio/SoundManager.cs • Auto-added with VehicleController
Sound Components
| Component | Default Volume | Position | Description |
|---|---|---|---|
| engineRunning | 0.21 | Engine | Main engine loop, RPM-driven pitch. |
| engineStart | 0.10 | Engine | One-shot starter motor sound. |
| engineFan | 0.071 | Engine | Cooling fan / belt whine. |
| exhaustPop | 0.415 | Exhaust | Backfire pops on deceleration. |
| turboWhistle | 0.012 | Engine | Turbo spool-up whistle. |
| turboFlutter | 0.052 | Engine | Blow-off valve flutter on throttle release. |
| gearShift | 0.763 | Transmission | Gear change clunk sound. |
| transmissionWhine | 0.006 | Transmission | Transmission gear whine. |
| tireSkid | 0.30 | Wheels | Tire screech on slip. |
| suspensionBump | 0.225 | Wheels | Bump/thud on suspension compression. |
| crash | 1.0 | Vehicle | Collision impact sound. |
Master Settings
| Property | Type | Default | Description |
|---|---|---|---|
| masterVolume | float | 1.0 | Global volume multiplier (0–2). |
| spatialBlend | float | 0 | 0 = 2D, 1 = full 3D positional audio. |
| enableInteriorAudio | bool | true | Toggle interior/exterior audio based on camera mode. |
| interiorVolumeMultiplier | float | 0.5 | Volume when in interior camera mode. |
| interiorLowPassCutoff | float | 1700 | Low-pass filter frequency for muffled interior sound. |
Positional Audio Offsets
| Property | Default | Description |
|---|---|---|
| enginePosition | (0, 0.5, 1.2) | Local offset for engine sounds (front of car). |
| exhaustPosition | (0, 0.2, -2) | Local offset for exhaust sounds (rear). |
| transmissionPosition | (0, 0.3, 0) | Local offset for transmission sounds (center). |
🎧 Vehicle Audio (Legacy)
Simpler audio system with two modes: Multi-Clip (4 crossfaded loops) or Single-Clip (pitch-based).
Script: Runtime/Audio/VehicleAudio.cs
Audio Modes
Multi-Clip Mode
4 engine loops (lowAccel, lowDecel, highAccel, highDecel) crossfaded by RPM and throttle. Most realistic.
4 Clips RequiredSingle-Clip Mode
One engine loop with pitch/volume mapped to RPM. Easy setup, good for mobile or simple games.
1 Clip Required🔥 Nitro System
Boost system with fuel management, particle effects, and auto-refill.
Script: Runtime/Systems/NitroSystem.cs
| Property | Type | Default | Description |
|---|---|---|---|
| enableNitro | bool | true | Master enable toggle. |
| boostForceMultiplier | float | 2.5 | Speed multiplier during boost. |
| maxBoostFuel | float | 100 | Total fuel capacity. |
| boostConsumptionRate | float | 20 | Fuel used per second while boosting. |
| autoRefill | bool | true | Auto-refill fuel when not boosting. |
| autoRefillRate | float | 10 | Fuel recovered per second. |
| useNitroBottles | bool | true | Enable bottle-based instant refills. |
| boostParticles | ParticleSystem[] | null | Flame/glow particles during boost. |
💥 Damage System
Real-time mesh deformation on collision. Supports MeshFilter and SkinnedMeshRenderer.
Script: Runtime/Systems/DamageSystem.cs
| Property | Type | Default | Description |
|---|---|---|---|
| maxHealth | float | 100 | Vehicle health points. |
| deformationRadius | float | 0.7 | Radius of vertex deformation from impact point (meters). |
| deformationStrength | float | 0.4 | How much vertices displace per unit of force. |
| maxDeformation | float | 0.4 | Maximum vertex displacement cap (meters). |
| smoothDamping | float | 0.3 | Deformation interpolation (lower = more gradual). |
| deformableMeshes | List | [] | Meshes that receive deformation (body panels, bumpers, etc.). |
damageSystem.Repair() or use the context menu "Repair Vehicle" to restore original mesh vertices and reset health.💡 Lighting System
Configurable light groups with key bindings, plus automatic brake and reverse lights.
Script: Runtime/Systems/LightingSystem.cs
Light Groups
Create unlimited light groups (headlights, fog lights, interior lights, etc.). Each group has a toggle key and list of GameObjects to enable/disable.
Brake & Reverse Lights
| Property | Default | Description |
|---|---|---|
| brakeLightObjects | [] | GameObjects activated when braking. |
| brakeColor | Red | Emission color for brake lights. |
| brakeIntensity | 2.0 | HDR emission intensity. |
| reverseLightColor | White | Emission color for reverse lights. |
| reverseIntensity | 3.0 | HDR emission intensity for reverse. |
🏇 Skid Mark System
Dynamic tire mark rendering using procedural mesh generation.
Script: Runtime/Systems/SkidMarkSystem.cs
| Property | Type | Default | Description |
|---|---|---|---|
| enableSkidMarks | bool | true | Master enable. |
| minSlipThreshold | float | 0.4 | Min wheel slip to start rendering marks. |
| markWidth | float | 0.2 | Width of each tire mark (meters). |
| maxMarks | int | 1024 | Maximum stored mark segments (ring buffer). |
| skidMarkMaterial | Material | null | Custom material. Auto-creates dark material if null. |
💨 Tire Smoke System
Per-wheel smoke particles driven by wheel slip. Auto-spawns from prefab or creates procedural particles.
Script: Runtime/Systems/TireSmokeSystem.cs
| Property | Type | Default | Description |
|---|---|---|---|
| smokePrefab | ParticleSystem | null | Custom smoke prefab (auto-cloned to each wheel). If null, creates procedural smoke. |
| minSlipThreshold | float | 0.35 | Min combined slip to emit smoke. |
| maxEmissionRate | float | 80 | Maximum particles per second. |
| driftEmissionMultiplier | float | 2.5 | Extra smoke during handbrake drift. |
| minSpeedKPH | float | 8 | No smoke below this speed. |
🎥 Vehicle Camera
3-mode camera system: Follow, Orbit, and Interior. Attach to Main Camera.
Script: Runtime/Camera/VehicleCamera.cs
Camera Modes
Follow Mode
Third-person chase camera with smooth damping, reverse-aware blending, and configurable distance/height.
Orbit Mode
Free orbit around vehicle with mouse. Includes collision detection to prevent clipping through walls.
Interior Mode
First-person cockpit view. Mouse look with angle limits. Triggers interior audio mode in SoundManager.
Follow Mode Properties
| Property | Default | Description |
|---|---|---|
| followDistance | 7.5 | Distance behind vehicle. |
| followHeight | 1.0 | Height above vehicle. |
| followSmoothTime | 0.08 | Camera lag (lower = tighter). |
| reverseConfirmDelay | 0.5s | Seconds before camera flips for reverse. |
| directionBlendSpeed | 2.0 | Camera flip transition speed. |
📈 Dashboard UI
In-game HUD showing speed, RPM gauge, gear indicator, nitro bar, and engine status.
Script: Runtime/UI/VehicleDashboard.cs • Requires: TextMeshPro
UI Slots
| Slot | Type | Description |
|---|---|---|
| speedText | TMP_Text | Displays current KPH. |
| rpmText | TMP_Text | Displays current RPM. |
| gearText | TMP_Text | Current gear or "R" for reverse. |
| rpmNeedle | Image | Rotated based on RPM (needleMinAngle to needleMaxAngle). |
| nitroSlider | Slider | Nitro fuel bar with color gradient (red→cyan). |
| engineStatusText | TMP_Text | "ENGINE: ON/OFF" with color coding. |
📱 Mobile Controls
Touch-based input with 3 steering modes.
Script: Runtime/Mobile/MobileInputHandler.cs
Steering Modes
Buttons
Left/Right arrow buttons for steering. Simple and reliable.
Drag
Touch and drag horizontally on screen to steer. Intuitive for casual games.
Wheel
Virtual steering wheel UI element. Most realistic mobile experience.
Button Assignments
| Button | Type | Description |
|---|---|---|
| gasButton | UI Button | Hold to accelerate. |
| brakeButton | UI Button | Hold to brake/reverse. |
| handbrakeButton | UI Button | Hold for handbrake/drift. |
| nitroButton | UI Button | Hold for nitro boost. |
| engineToggleButton | UI Button | Tap to start/stop engine. |
| cameraSwitchButton | UI Button | Tap to cycle camera modes. |
🤖 AI Vehicle Controller
Autonomous driving AI with 4 behavior modes, integrated GPS pathfinding, obstacle avoidance, and predictive targeting.
Script: Runtime/AI/AIVehicleController.cs • Requires: VehicleController
Detection Settings
| Property | Default | Description |
|---|---|---|
| forwardRays | 9 | Number of forward-facing detection rays. |
| forwardMaxDistance | 30 | Forward ray detection range (meters). |
| forwardRaySpread | 80 | Angular spread of forward rays (degrees). |
| sideRays / rearRays | 5 / 7 | Side and rear detection rays. |
| obstacleDetectionRadius | 1.0 | SphereCast radius for obstacle detection. |
Intelligence
| Property | Default | Description |
|---|---|---|
| safeDistance | 12 | Comfortable distance from obstacles. |
| dangerDistance | 5 | Active avoidance begins. |
| emergencyDistance | 2 | Emergency steering/braking. |
| steeringHelper | 3.0 | How aggressively AI corrects steering (higher = sharper). |
| enablePredictiveTargeting | true | AI predicts where moving target will be. |
| maxPredictionTime | 2.5s | Max time ahead for target prediction. |
Speed & Handling
| Property | Default | Description |
|---|---|---|
| maxSpeedPercent | 1.0 | Throttle cap (0.5 = half speed). |
| cornerSpeedMultiplier | 0.65 | Speed reduction in turns. |
| brakingDistance | 20 | Distance to start braking for target. |
| waypointReachedDistance | 10 | How close to reach before advancing waypoint. |
🗺 GPS Pathfinder
Integrated A* pathfinding with async grid scanning for zero FPS impact. Finds optimal paths around complex obstacles.
| Property | Range | Default | Description |
|---|---|---|---|
| enableGPS | bool | true | Enable A* pathfinding navigation. |
| gpsGridSize | Vector2 | (80, 80) | World size of scanning grid. |
| gpsNodeRadius | 0.5–2 | 0.75 | Grid cell size. Smaller = more precise. |
| gpsObstaclePadding | 0.5–6 | 2.0 | Extra clearance around obstacles. |
| gpsProximityPenalty | 0–150 | 50 | A* cost penalty near obstacles. |
| gpsSmoothingClearance | 0.5–3 | 1.2 | SphereCast radius for path smoothing. |
| gpsLookahead | 5–30 | 15 | How far ahead on path to steer toward. |
| gpsInfluence | 0–1 | 0.45 | Blend between GPS and reactive steering. |
🛠 AI Modes
4 behavior modes for different gameplay scenarios.
General
Follows waypoint sequence. Stops at final waypoint. Best for traffic, patrols, cutscenes.
Waypoints RequiredRacing
Follows waypoint circuit with loop. Optimizes speed, takes racing lines. Best for racing AI opponents.
Waypoints RequiredFollow Aggressive
Pursues target vehicle at close range (3m). Uses GPS + reactive avoidance. Best for police chases.
Follow Target RequiredFollow Friendly
Follows target at comfortable distance (25m). Gentle braking, safe pursuit. Best for escort missions.
Follow Target RequiredDrive States
The AI operates through an internal state machine: Forward → SlowingDown → Turning → Reversing → EscapingStuck → AggressiveChase. States are shown in the Debug Info section of the inspector.
🔧 Vehicle Creator Wizard
One-click vehicle setup editor window.
Script: Editor/VehicleCreatorWindow.cs • Menu: Tools → Abyssal Ababeel → Vehicle Creator Wizard
Features
- Auto-creates Rigidbody, WheelColliders, and all components
- 7 built-in presets (Sports, Sedan, SUV, Racing, Truck, Offroad, Van)
- Optional systems: AI, Nitro, Damage, Lighting, SkidMarks, TireSmoke, Dashboard
- Auto-generates gear ratios based on speed and RPM
- Creates center of mass transform
- Supports both SoundManager and VehicleAudio
🗻 Runtime Pathfinder
Standalone A* pathfinding component with visual debugging. Can be used independently of the AI system.
Script: Runtime/Pathfinder/RuntimePathfinder.cs
| Property | Default | Description |
|---|---|---|
| gridWorldSize | (40, 40) | Grid coverage area in meters. |
| nodeRadius | 0.5 | Cell size (smaller = higher resolution). |
| obstacleMask | - | LayerMask for obstacles. |
| initialPoint / targetPoint | - | Path start and end transforms. |
| autoUpdatePath | false | Recompute path every frame. |
| showPath / showGrid | true | Gizmo visualization toggles. |
⌨ Default Controls
Default keyboard bindings (all configurable in VehicleInput inspector).
| Action | Key | Notes |
|---|---|---|
| Accelerate | W / ↑ | Throttle input (0–1 analog). |
| Brake / Reverse | S / ↓ | Brake when moving forward, reverse when stopped. |
| Steer Left | A / ← | Analog steering. |
| Steer Right | D / → | Analog steering. |
| Handbrake | Space | Rear wheel lock. Hold for drift (if enabled). |
| Shift Up | E | Manual transmission only. |
| Shift Down | Q | Manual transmission only. |
| Engine Toggle | F | Start/Stop engine. |
| Nitro Boost | Left Shift | Hold while driving. Requires NitroSystem. |
| Switch Camera | Tab | Cycle: Follow → Orbit → Interior. |
💻 Public API Reference
Key methods available for scripting integration.
VehicleController
// Engine control
vehicleController.StartEngine();
vehicleController.StopEngine();
vehicleController.ToggleEngine();
// Runtime properties
float speed = vehicleController.KPH;
float rpm = vehicleController.engineRPM;
float rpmNorm = vehicleController.RPMPercent; // 0-1
float load = vehicleController.EngineLoad; // 0-1
int gear = vehicleController.currentGear;
bool reversing = vehicleController.isReversing;
NitroSystem
float fuelPercent = nitroSystem.GetBoostFuelPercent(); // 0-1
float fuelCurrent = nitroSystem.GetCurrentBoostFuel();
float fuelMax = nitroSystem.GetMaxBoostFuel();
bool boosting = nitroSystem.IsBoosting();
DamageSystem
damageSystem.Repair(); // Restore all meshes to original state
VehicleCamera
vehicleCamera.CycleCamera(); // Next camera mode
vehicleCamera.currentMode = VehicleCamera.CameraMode.Interior;
VehicleInput
vehicleInput.SetInputMode(VehicleInput.InputMode.Mobile);
vehicleInput.isAIControlled = true; // Disable human input
AIVehicleController
aiController.GPSForceRescan(); // Force new pathfinding scan
🔍 Troubleshooting
Common issues and solutions.