NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class 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:

    1. Assign a fallback surface preset (required)
    2. Configure surface maps for terrain textures and object tags
    3. Set up particle prefabs for visual effects (optional)
    4. 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
    Inheritance
    object
    Object
    ScriptableObject
    GroundDetectionPreset
    Namespace: NWH.VehiclePhysics2.GroundDetection
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    [Serializable]
    [CreateAssetMenu(fileName = "NWH Vehicle Physics 2", menuName = "NWH/Vehicle Physics 2/Ground Detection Preset", order = 1)]
    public class GroundDetectionPreset : ScriptableObject

    Fields

    chunkPrefab

    Particle system prefab for generating surface chunks (dirt, stones, debris) that get thrown behind wheels when traveling over soft surfaces. The particle system should be configured to emit appropriate chunk-like particles. Used when SurfacePreset.emitChunks is enabled for a surface type.

    Leave null if no chunk effects are needed. The same prefab is used for all surface types that enable chunk emission, with individual chunk properties controlled by the SurfacePreset settings (emission rate, lifetime, distance).

    Typical setup:

    • Particle system with 3D mesh renderer (stones, dirt clumps, debris)
    • Physics simulation with gravity and collision
    • Short lifetime (0.5-2 seconds)
    • Emission controlled by code based on wheel slip and speed
    Declaration
    [Tooltip("Prefab of the particle system for generating surface chunks / dirt that gets thrown behind the wheel when going over soft surface.")]
    public GameObject chunkPrefab
    Field Value
    Type Description
    GameObject

    fallbackSurfacePreset

    Surface preset used as a fallback when no surface maps match the current terrain texture or object tag. This preset is critical for ensuring vehicles always have valid friction and surface properties.

    REQUIRED: This field must be assigned for ground detection to work properly. Typically set to a generic surface preset representing the most common surface type in your scene (e.g., asphalt, grass, or a neutral preset).

    The fallback is used when:

    • No terrain textures match any SurfaceMap
    • No object tags match any SurfaceMap
    • Wheel is on an untagged object that isn't a terrain
    • As a safety net to prevent null reference errors

    Best practice: Use a middle-ground friction preset that works reasonably well on most surfaces.

    Declaration
    [Tooltip("Surface preset used when there are no matches in the surfaceMaps list for the current surface.")]
    public SurfacePreset fallbackSurfacePreset
    Field Value
    Type Description
    SurfacePreset

    particlePrefab

    Particle system prefab for generating dust or smoke effects from wheel contact with surfaces. The system generates dust (for sand, gravel, dirt) or smoke (for asphalt, concrete) depending on the surface type and ParticleType setting in the SurfacePreset.

    Used when SurfacePreset.emitParticles is enabled. The particle color and other properties are controlled by individual SurfacePreset settings. Leave null if no particle effects are needed.

    Typical setup:

    • Particle system with billboard renderer
    • Color and alpha controlled by SurfacePreset
    • Emission rate controlled by wheel slip (smoke) or speed (dust)
    • Velocity inheritance from wheel motion
    • Fade out over lifetime

    The same prefab is used for all surfaces, with appearance modified by SurfacePreset parameters.

    Declaration
    [FormerlySerializedAs("dustPrefab")]
    [Tooltip("Prefab of the particle system for generating dust as a result of traveling over sand, gravel, etc.")]
    public GameObject particlePrefab
    Field Value
    Type Description
    GameObject

    surfaceMaps

    Collection of surface maps that define how terrain textures and object tags are mapped to surface presets. Each SurfaceMap represents a unique surface type and contains:

    • Lists of terrain texture indices that represent this surface
    • Lists of object tags that should be treated as this surface
    • Reference to the SurfacePreset defining surface properties

    The ground detection system iterates through this list to find matches for the current wheel contact. Order matters for tag checking: earlier entries take priority in case of conflicts.

    Setup workflow:

    1. Create SurfacePresets for each surface type (asphalt, grass, dirt, etc.)
    2. Add SurfaceMaps to this list
    3. Configure each SurfaceMap with terrain texture indices or object tags
    4. Assign the appropriate SurfacePreset to each SurfaceMap

    Example configuration:

    • SurfaceMap "Asphalt": texture index 0, tag "Road", SurfacePreset with high friction
    • SurfaceMap "Grass": texture indices 1,2, tag "Grass", SurfacePreset with medium friction
    • SurfaceMap "Sand": texture index 3, tag "Sand", SurfacePreset with low friction and dust particles
    Declaration
    [Tooltip("Surface maps - each represents a single ground surface.")]
    public List<SurfaceMap> surfaceMaps
    Field Value
    Type Description
    List<SurfaceMap>

    See Also

    GroundDetection
    SurfaceMap
    SurfacePreset
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics