Class ModuleTemplate
Template for a custom vehicle module. Copy it and fill in the lifecycle methods.
Inherited Members
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
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
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. |