NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class ModuleTemplate

    Template for creating custom vehicle modules. Demonstrates the basic structure and lifecycle methods needed for a functional module. Copy this template to create new modules that extend vehicle functionality.

    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

    Module lifecycle:

    1. VC_Initialize() - Called once when the module is first set up
    2. VC_Enable() - Called when the module is enabled (inherited from VehicleComponent)
    3. VC_Update() - Called each frame while the module is active
    4. VC_FixedUpdate() - Called at fixed physics timesteps while the module is active
    5. VC_Disable() - Called when the module is disabled (inherited from VehicleComponent)

    Access vehicle data through the vehicleController reference inherited from VehicleComponent.

    Fields

    floatExample

    Example float field demonstrating how to create serialized properties. Use [Range] attribute to add 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 demonstrating collection types. Use new() for initialization to avoid null reference issues.

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

    Methods

    VC_FixedUpdate(float)

    Called at fixed physics timesteps when the module is active. Use this for physics-related updates such as applying forces, torques, or modifying wheel behavior.

    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()

    Initializes the module. Called once when the module is first set up. Override this method to perform one-time initialization, cache references, or validate configuration. Call base.VC_Initialize() at the end after your initialization logic succeeds.

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

    VC_Update(float)

    Called every frame when the module is active. Use this for non-physics updates such as input handling, visual effects, or animations.

    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