NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class MotorcycleModuleWrapper

    MonoBehaviour wrapper for the Motorcycle module.

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

    Required component wrapper that allows the MotorcycleModule to be attached to a GameObject with a VehicleController. The wrapper handles Unity's MonoBehaviour lifecycle and serialization while delegating the actual motorcycle physics to the contained module.

    Add this component to a two-wheeled vehicle GameObject through: - Unity Editor: Add Component > NWH > Vehicle Physics 2 > Modules > Motorcycle Module - Script: gameObject.AddComponent<MotorcycleModuleWrapper>()

    Important: The vehicle must have exactly 2 wheels configured in the powertrain, with the front wheel at index 0 and rear wheel at index 1. The module will assert this requirement during initialization.

    The module can be accessed at runtime through the module field for dynamic tuning of PID parameters, lean limits, or querying wheelie/stoppie states.

    Fields

    module

    The MotorcycleModule instance managed by this wrapper.

    Declaration
    public MotorcycleModule module
    Field Value
    Type Description
    MotorcycleModule
    Remarks

    Access this field to tune motorcycle behavior, adjust PID parameters, or query states like wheelie detection at runtime.

    Key runtime adjustments: - PID gains for balance tuning - Lean angle limits for different riding modes - Max lean torque for stability vs realism balance - Visual transform references for animations

    Methods

    GetModule()

    Returns the contained MotorcycleModule as a VehicleComponent.

    Declaration
    public override VehicleComponent GetModule()
    Returns
    Type Description
    VehicleComponent

    The MotorcycleModule instance cast to VehicleComponent.

    Overrides
    ModuleWrapper.GetModule()

    SetModule(VehicleComponent)

    Sets the contained module from a VehicleComponent reference.

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

    The VehicleComponent to set, must be a MotorcycleModule instance.

    Overrides
    ModuleWrapper.SetModule(VehicleComponent)
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics