Namespace NWH.VehiclePhysics2.GroundDetection
Classes
GroundDetection
Detects surface type under each wheel using tags (priority), terrain splatmaps, or fallback. Applies per-surface friction presets, rolling resistance, and visual/audio effects. Runs via coroutine at groundDetectionInterval. Tracks dominantSurfacePreset across all wheels.
GroundDetectionPreset
A ScriptableObject that centralizes ground detection configuration for vehicles. Contains a collection of SurfaceMaps that define how different terrain textures and object tags are mapped to surface types, along with particle prefabs and fallback settings.
This preset system prevents the need to configure ground detection settings individually on each vehicle. Typically one preset is created per scene or project, though multiple presets can be used for different vehicle types or environments.
The preset manages:
- Surface detection mappings (terrain textures and object tags to surface properties)
- Particle effect prefabs for dust/smoke and surface chunks
- Fallback surface preset for unmatched surfaces
- Shared configuration across multiple vehicles
Create via: Right-click in Project window > Create > NWH > Vehicle Physics 2 > Ground Detection Preset
Essential setup:
- Assign a fallback surface preset (required)
- Configure surface maps for terrain textures and object tags
- Set up particle prefabs for visual effects (optional)
- Assign to vehicle's GroundDetection component
Workflow:
- Create one or more SurfacePresets defining properties for each surface type
- Create SurfaceMaps to link terrain textures/tags to those presets
- Assign this preset to vehicles that should use these surface definitions
SurfaceMap
Defines the mapping between a specific surface type and the methods used to detect it. Links terrain texture indices and/or object tags to a SurfacePreset that defines the surface properties.
Each SurfaceMap represents a unique surface type in your scene and specifies:
- Which terrain texture indices should be treated as this surface type
- Which object tags should be treated as this surface type
- The SurfacePreset that defines friction, visual effects, and audio for this surface
Detection priority: Ground detection prioritizes tag-based detection over terrain texture detection. This allows objects (roads, bridges, ramps) to override terrain textures beneath them.
Usage scenarios:
- Map terrain texture 0 (grass) to a grass SurfacePreset
- Map object tag "Road" to an asphalt SurfacePreset
- Map multiple terrain textures (dirt variations) to the same dirt SurfacePreset
- Override terrain with tagged objects for special surface areas
If both lists are empty, this surface map will never be matched.
SurfacePreset
ScriptableObject defining a surface type's friction, particles, skidmarks, and audio. Applied to wheels via SurfaceMaps based on terrain texture or object tag. FrictionPreset assignment is required for proper grip - everything else is optional. Create via: Right-click > Create > NWH > Vehicle Physics 2 > Surface Preset
Enums
SurfacePreset.ParticleType
Determines particle emission behavior.