NWH Wheel Controller 3D
Search Results for

    Show / Hide Table of Contents

    Class StandardGroundDetection

    Default ground detection implementation using immediate synchronous sphere casts. Provides accurate 3D collision detection across the wheel's surface with same-frame results for maximum accuracy at high speeds.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    GroundDetectionBase
    StandardGroundDetection
    Namespace: NWH.WheelController3D
    Assembly: NWH.WheelController.dll
    Syntax
    [RequireComponent(typeof(WheelController))]
    public class StandardGroundDetection : GroundDetectionBase
    Remarks

    StandardGroundDetection provides two detection modes:

    • Sphere: Single wide sphere cast from wheel center (faster)
    • Multicast: Multiple sphere casts across wheel circumference (most accurate)

    All sphere casts are performed immediately within the same physics frame, eliminating temporal lag that can cause suspension compression issues at high speeds (200+ km/h).

    Performance characteristics:

    • Synchronous execution ensures accurate hit point detection
    • No frame delay between cast and result
    • Very narrow wheels (width less than 0.01m) automatically use raycasts
    • Multicast mode performs 3-7 casts per wheel depending on wheel radius

    When to use each mode:

    • Sphere: AI vehicles, mobile platforms, vehicles that stay on flat surfaces
    • Multicast: Player vehicles, off-road games, high-speed racing, climbing/parkour vehicles, sim racing

    Fields

    | Edit this page View Source

    castType

    Determines the ground detection algorithm used for this wheel.

    Declaration
    public StandardGroundDetection.CastType castType
    Field Value
    Type Description
    StandardGroundDetection.CastType

    Methods

    | Edit this page View Source

    WheelCast(in Vector3, in Vector3, in float, in float, in float, ref WheelHit, LayerMask)

    Performs a collision cast to detect ground contact beneath the wheel. Called every physics frame to update wheel ground contact state.

    Declaration
    public override bool WheelCast(in Vector3 origin, in Vector3 direction, in float distance, in float wheelRadius, in float wheelWidth, ref WheelHit wheelHit, LayerMask layerMask)
    Parameters
    Type Name Description
    Vector3 origin

    Cast starting point in world space (typically wheel suspension origin)

    Vector3 direction

    Cast direction in world space (typically vehicle's down vector)

    float distance

    Maximum cast distance in meters (typically suspension max length + wheel radius)

    float wheelRadius

    Wheel radius in meters, defines the wheel's circular boundary

    float wheelWidth

    Wheel width in meters, defines the lateral extent of the tire

    WheelHit wheelHit
    LayerMask layerMask

    Physics layer mask determining which layers can be detected

    Returns
    Type Description
    bool

    True if ground was detected within the cast distance, false if wheel is airborne

    Overrides
    GroundDetectionBase.WheelCast(in Vector3, in Vector3, in float, in float, in float, ref WheelHit, LayerMask)
    Remarks

    When returning true, implementation must populate result with:

    • point: World-space contact point
    • normal: Surface normal at contact point (unit vector)
    • collider: The Collider component that was hit
    • localPoint/localNormal: Optional; providing these avoids matrix transformations in the caller

    Important considerations:

    • Only detect the bottom hemisphere of the wheel (top collisions handled separately)
    • Exclude vehicle's own colliders to prevent self-collision
    • Return the closest hit if multiple surfaces are detected
    • Consider wheel width - hits outside the tire width should be ignored
    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics