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.
Inherited Members
Namespace: NWH.VehiclePhysics2.Modules.ModuleTemplate
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class ModuleTemplate : VehicleComponent
Remarks
Module lifecycle:
- VC_Initialize() - Called once when the module is first set up
- VC_Enable() - Called when the module is enabled (inherited from VehicleComponent)
- VC_Update() - Called each frame while the module is active
- VC_FixedUpdate() - Called at fixed physics timesteps while the module is active
- 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
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
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. |