NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    LOD System

    Performance optimization via distance-based component activation/deactivation.

    Overview

    System monitors vehicle-to-camera distance and adjusts active components per StateSettings configuration. Updates every 0.2s.

    • lodCamera - Camera for distance checks (uses Camera.main if null)
    • activeLODIndex - Current LOD level
    • vehicleToCamDistance - Distance in meters
    • onLODChanged - UnityEvent fired on LOD transition

    LOD Levels

    Defined in StateSettings:

    LOD 0: 0-30m (close, full detail)
    LOD 1: 30-100m (medium, reduced)
    LOD 2: 100-300m (far, minimal)
    LOD 3: 300m+ (very far)
    

    Distances and component states are fully configurable.

    Component Behavior

    Component lodIndex:

    • -1: Ignore LOD (always active)
    • 0+: Follow StateSettings LOD rules

    Components enable/disable automatically on LOD change.

    StateSettings Configuration

    Create: Right-click > Create > NWH > Vehicle Physics 2 > State Settings

    Per LOD level, set:

    • Name (e.g. "Close", "Medium", "Far")
    • Distance threshold (meters)
    • Component enable/disable states

    Example LOD 1 (30-100m):

    • Powertrain: Enabled
    • Effects: Skidmarks only
    • Sound: Engine + transmission
    • Modules: ABS/TCS only

    Recommended Distances

    Desktop (60 FPS):

    • LOD 0: 0-40m
    • LOD 1: 40-120m
    • LOD 2: 120-400m

    Mobile (30 FPS):

    • LOD 0: 0-25m
    • LOD 1: 25-75m
    • LOD 2: 75-200m

    Disable Order

    As distance increases, disable in this order:

    1. Effects (particles, skidmarks)
    2. Sound
    3. Non-critical modules
    4. Critical modules (ABS, TCS)
    5. Powertrain (last resort)

    Multi-Camera

    For split-screen, assign lodCamera per vehicle. Each vehicle tracks its assigned camera independently.

    Events

    vehicleController.onLODChanged.AddListener(() => {
        // Custom LOD logic
    });
    

    Debugging

    Check in inspector while running:

    • activeLODIndex
    • vehicleToCamDistance
    • Verify components enable/disable

    Common Issues

    LOD not changing: Check StateSettings assigned, verify lodCamera valid

    Components not responding: Confirm lodIndex ≥ 0, verify component in StateSettings list

    No performance gain: Profile to confirm components actually disabling, check LOD distances

    Performance Impact

    With proper setup:

    • 5-10 vehicles: 10-20% CPU reduction
    • 10-20 vehicles: 30-50% CPU reduction
    • 20+ vehicles: 50-70% CPU reduction

    Gains depend on which components disabled and at what distances.

    Best Practices

    • Test with multiple vehicles (LOD most important at scale)
    • Profile actual gains
    • Start conservative, tighten based on measurements
    • Platform-specific StateSettings
    • Keep player vehicle at LOD 0 (optional)
    • Disable effects before physics
    • Combine with Rigidbody sleep for distant vehicles
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics