Vehicle State Settings
ScriptableObject defining vehicle behavior profiles, primarily for LOD system configuration.
Purpose
- LOD configuration (which components active at each distance)
- Performance profiles (Desktop/Mobile/Console)
- Quality presets (High/Medium/Low)
Creation
Right-click > Create > NWH > Vehicle Physics 2 > State Settings
Name appropriately: DesktopStateSettings, MobileStateSettings, etc.
Assignment
- Per vehicle: VehicleController inspector > State Settings field
- Default: Loads from Resources if not assigned
- Runtime: Can swap via code
Configuration
LOD Levels
Each LOD defines:
- Distance: Max distance in meters for this LOD
- Name: Descriptive label ("Close", "Medium", "Far")
- Component States: Which components enabled at this LOD
Example:
LOD 0 (0-40m): All enabled
LOD 1 (40-120m): Powertrain + Engine sound + Skidmarks
LOD 2 (120m+): Powertrain only
Component States
For each component:
- Enabled:
VC_Update()andVC_FixedUpdate()called, active processing - Disabled: No updates, no resource usage
Component lodIndex:
-1: Always active (ignores StateSettings)0+: Follows StateSettings
Platform Profiles
Create separate StateSettings per platform:
#if UNITY_STANDALONE
vc.stateSettings = desktopSettings;
#elif UNITY_MOBILE
vc.stateSettings = mobileSettings;
#endif
Desktop Example
LOD 0 (0-40m): Full LOD 1 (40-120m): Skidmarks + core sounds LOD 2 (120m+): Minimal
Mobile Example
LOD 0 (0-25m): Reduced effects LOD 1 (25-75m): Core only LOD 2 (75m+): Minimal
Runtime Management
Swap settings:
vc.stateSettings = lowQualitySettings;
vc.StateSettingsChanged();
Dynamic quality adjustment:
if (averageFPS < 30) {
foreach (var vehicle in vehicles) {
vehicle.stateSettings = lowQualitySettings;
vehicle.StateSettingsChanged();
}
}
Best Practices
- Test each LOD level
- Platform-specific profiles
- Start conservative, optimize based on profiling
- Keep critical components (Input, core physics) at
lodIndex = -1 - Disable effects before physics at higher LODs
- Version control StateSettings assets
- Share common settings across vehicles
Troubleshooting
Components not disabling: Check lodIndex ≥ 0, verify StateSettings assigned, confirm component in StateSettings list
No performance gain: Profile to verify disabling actually happens, check LOD distances
Unexpected behavior: Verify correct StateSettings for platform, check component states for active LOD
Integration
StateSettings is the backbone of the LOD system. See LOD System.
Flow:
- VehicleController measures distance to camera
- Active LOD determined by distance vs StateSettings thresholds
- Component states read from StateSettings
- Components enabled/disabled per configuration