NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class TrailerHitchModuleWrapper

    MonoBehaviour wrapper for the TrailerHitchModule.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    ModuleWrapper
    TrailerHitchModuleWrapper
    Namespace: NWH.VehiclePhysics2.Modules.Trailer
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    [Serializable]
    [DisallowMultipleComponent]
    public class TrailerHitchModuleWrapper : ModuleWrapper
    Remarks

    This wrapper enables the TrailerHitchModule to be added as a Unity component and handles the creation and management of the attachment point trigger collider. The wrapper must be added to a GameObject with a VehicleController.

    The wrapper automatically creates a SphereCollider trigger at the attachment point during Awake(), which is used to detect nearby trailers. It also provides visual feedback in the Scene view through Gizmos.

    Fields

    module

    The wrapped TrailerHitchModule instance.

    Declaration
    public TrailerHitchModule module
    Field Value
    Type Description
    TrailerHitchModule
    Remarks

    Contains all configuration and runtime state for the trailer hitch system. Access this property to modify hitch settings or check attachment status.

    Methods

    GetModule()

    Gets the wrapped module as a VehicleComponent.

    Declaration
    public override VehicleComponent GetModule()
    Returns
    Type Description
    VehicleComponent

    The TrailerHitchModule instance cast to VehicleComponent

    Overrides
    ModuleWrapper.GetModule()
    Remarks

    Used by the module system for generic module handling and lifecycle management.

    OnTriggerEnter(Collider)

    Forwards trigger enter events to the wrapped module.

    Declaration
    public void OnTriggerEnter(Collider other)
    Parameters
    Type Name Description
    Collider other

    The collider that entered the trigger

    Remarks

    Unity trigger events are received by the wrapper and forwarded to the module for processing trailer detection logic.

    OnTriggerExit(Collider)

    Forwards trigger exit events to the wrapped module.

    Declaration
    public void OnTriggerExit(Collider other)
    Parameters
    Type Name Description
    Collider other

    The collider that exited the trigger

    OnTriggerStay(Collider)

    Forwards trigger stay events to the wrapped module.

    Declaration
    public void OnTriggerStay(Collider other)
    Parameters
    Type Name Description
    Collider other

    The collider staying in the trigger

    Remarks

    Maintains awareness of trailers remaining in the attachment zone.

    SetModule(VehicleComponent)

    Sets the wrapped module from a VehicleComponent reference.

    Declaration
    public override void SetModule(VehicleComponent module)
    Parameters
    Type Name Description
    VehicleComponent module

    The VehicleComponent to wrap, must be a TrailerHitchModule instance

    Overrides
    ModuleWrapper.SetModule(VehicleComponent)
    Remarks

    Used by the module system when dynamically creating or replacing modules. The provided module must be castable to TrailerHitchModule.

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