NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class ModuleTemplate

    Template for a custom vehicle module. Copy it and fill in the lifecycle methods.

    Inheritance
    object
    VehicleComponent
    ModuleTemplate
    Inherited Members
    VehicleComponent.state
    VehicleComponent.vehicleController
    VehicleComponent.IsActive
    VehicleComponent.VC_Initialize(VehicleController)
    VehicleComponent.VC_SetDefaults()
    VehicleComponent.VC_LoadStateFromStateSettings()
    VehicleComponent.VC_Enable(bool)
    VehicleComponent.VC_Disable(bool)
    VehicleComponent.VC_DrawGizmos()
    VehicleComponent.VC_Validate(VehicleController)
    VehicleComponent.UpdateLOD()
    VehicleComponent.ToggleState()
    Namespace: NWH.VehiclePhysics2.Modules.ModuleTemplate
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    [Serializable]
    public class ModuleTemplate : VehicleComponent
    Remarks

    Call order: VC_Initialize() once at setup, VC_Enable() on enable, then VC_Update() per frame and VC_FixedUpdate() per physics step while active, VC_Disable() on disable. Vehicle data is reached through the inherited vehicleController reference.

    Fields

    floatExample

    Example serialized field. [Range] gives it a slider in the inspector.

    Declaration
    [Range(0, 1)]
    [Tooltip("Example float field.")]
    public float floatExample
    Field Value
    Type Description
    float

    listExample

    Example list field. Initialized with new() so it is never null.

    Declaration
    [Tooltip("Example list field.")]
    public List<int> listExample
    Field Value
    Type Description
    List<int>

    Methods

    VC_FixedUpdate(float)

    Fixed physics step while the module is active. Forces, torques and wheel changes belong here.

    Declaration
    public override void VC_FixedUpdate(float DeltaTime)
    Parameters
    Type Name Description
    float DeltaTime

    Time elapsed since the last fixed update.

    Overrides
    VehicleComponent.VC_FixedUpdate(float)

    VC_Initialize()

    One-time setup: cache references, validate configuration. Call base.VC_Initialize() last, once the setup has succeeded.

    Declaration
    protected override void VC_Initialize()
    Overrides
    VehicleComponent.VC_Initialize()

    VC_Update(float)

    Per-frame update while the module is active. Input, visuals and animation belong here.

    Declaration
    public override void VC_Update(float DeltaTime)
    Parameters
    Type Name Description
    float DeltaTime

    Time elapsed since the last frame.

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