Class NOSModule
Nitrous Oxide System (NOS) module for NWH Vehicle Physics 2.
Inherited Members
Namespace: NWH.VehiclePhysics2.Modules
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class NOSModule : VehicleComponent
Remarks
The NOS module provides a temporary power boost by injecting nitrous oxide into the engine, increasing oxygen availability for combustion. This results in a significant but temporary increase in engine power output, commonly used for drag racing and short bursts of acceleration.
The system simulates a realistic NOS bottle with limited capacity that depletes during use. Power boost is applied as a multiplier to the engine's base output, and various safety conditions prevent NOS activation in inappropriate situations.
Key features: - Finite NOS bottle capacity with adjustable flow rate - Safety lockouts for reverse gear and off-throttle conditions - Integration with engine sound and exhaust visual effects - Automatic exhaust flash triggering during NOS activation
The module automatically manages the exhaust flash effect when NOS is active, creating the characteristic flame effect associated with nitrous systems. Sound and visual intensity coefficients allow fine-tuning of the sensory feedback.
Fields
capacity
Maximum capacity of the NOS bottle in kilograms.
Declaration
[Tooltip("Maximum capacity of the NOS bottle in kilograms.")]
public float capacity
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Determines the total amount of nitrous oxide available. The bottle can be refilled by setting the charge value back to capacity.
Typical values: - Small bottle: 0.5-1.0 kg (5-10 seconds of boost) - Standard bottle: 2.0-3.0 kg (20-30 seconds of boost) - Large bottle: 5.0-10.0 kg (50-100 seconds of boost)
charge
Current amount of NOS remaining in the bottle in kilograms.
Declaration
[Tooltip("Current amount of NOS remaining in the bottle in kilograms.")]
public float charge
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Depletes during use based on the flow rate. When charge reaches zero, NOS boost is no longer available until refilled. Can be modified at runtime to simulate refilling or partial bottles.
Set equal to capacity for a full bottle, or lower values for partially filled bottles. Monitor this value to display remaining NOS on UI gauges.
disableInReverse
Prevents NOS activation when the vehicle is in reverse gear.
Declaration
[Tooltip("Prevents NOS activation when the vehicle is in reverse gear.")]
public bool disableInReverse
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
Safety feature that prevents NOS use during reverse movement. Enable this for realistic behavior, disable for arcade-style gameplay where NOS should work in all situations.
disableOffThrottle
Prevents NOS activation when throttle input is below 50%.
Declaration
[Tooltip("Prevents NOS activation when throttle input is below 50%.")]
public bool disableOffThrottle
Field Value
| Type | Description |
|---|---|
| bool |
Remarks
Simulates the requirement for engine load before NOS can be safely injected. In real systems, NOS without sufficient throttle can cause engine damage.
When enabled, requires throttle position > 0.5 for NOS to activate. Disable for more arcade-style behavior where NOS works independently of throttle.
engineVolumeCoefficient
Multiplier for engine sound volume during NOS activation.
Declaration
[Range(1, 3)]
[Tooltip("Multiplier for engine sound volume during NOS activation. Applied to the engine running sound component.")]
public float engineVolumeCoefficient
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Increases the engine sound intensity to reflect the additional combustion from NOS injection. Applied to the engine running sound component's volume range.
Values: - 1.0: No change in engine volume - 1.5: 50% louder (typical setting) - 2.0-3.0: Very aggressive sound increase
exhaustEmissionCoefficient
Multiplier for exhaust smoke particle emission during NOS activation.
Declaration
[Range(1, 3)]
[Tooltip("Multiplier for exhaust smoke particle emission during NOS activation.")]
public float exhaustEmissionCoefficient
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Increases the visual intensity of exhaust smoke to simulate the richer combustion mixture when NOS is active. Creates more dramatic visual feedback.
Values: - 1.0: No change in exhaust smoke - 2.0: Double the particle emission (typical setting) - 3.0: Triple emission for very dramatic effect
flow
Rate of NOS consumption in kilograms per second.
Declaration
[Tooltip("Rate of NOS consumption in kilograms per second.")]
public float flow
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Determines how quickly the NOS bottle depletes during use. Higher flow rates provide more power but deplete the bottle faster.
Typical values: - 0.05 kg/s: Economy setting, longer duration - 0.1 kg/s: Standard flow rate - 0.2-0.3 kg/s: High flow for maximum power
Duration = capacity / flow Example: 2 kg capacity / 0.1 kg/s flow = 20 seconds of boost
nosSoundComponent
Sound component for NOS-specific audio effects.
Declaration
[SerializeField]
public NOSSoundComponent nosSoundComponent
Field Value
| Type | Description |
|---|---|
| NOSSoundComponent |
Remarks
Handles the characteristic hissing sound of NOS injection. Automatically managed by the module and integrated with the vehicle's sound system.
powerCoefficient
Engine power multiplier applied when NOS is active.
Declaration
[Range(1, 5)]
[Tooltip("Engine power multiplier applied when NOS is active. 2.0 = double power, 3.0 = triple power, etc.")]
public float powerCoefficient
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Directly multiplies the engine's power output when NOS is engaged. This simulates the increased combustion efficiency from additional oxygen.
Typical values: - 1.5: 50% power increase (mild NOS system) - 2.0: 100% power increase (standard system) - 3.0-5.0: 200-400% increase (competition system)
Higher values may require suspension and tire upgrades to handle the additional power.
Properties
IsUsingNOS
Indicates whether NOS is currently being used.
Declaration
public bool IsUsingNOS { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
Read-only property that checks all conditions for NOS activation: boost input active, charge remaining, not in reverse (if restricted), and sufficient throttle (if required).
Methods
NOSPowerModifier(float)
Calculates the engine power modifier based on NOS activation state.
Declaration
public float NOSPowerModifier(float DeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | DeltaTime | Physics time step in seconds |
Returns
| Type | Description |
|---|---|
| float | Power multiplier to be applied to engine output. Returns powerCoefficient when NOS is active, 1.0 otherwise. |
Remarks
This method is registered with the engine's power modifiers list. It depletes the NOS charge when active and triggers the exhaust flash effect. Called every physics frame when the module is enabled.
VC_Disable(bool)
Disables the NOS module and unregisters the power modifier from the engine.
Declaration
public override bool VC_Disable(bool calledByParent)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | calledByParent | True if called by parent component, false otherwise. |
Returns
| Type | Description |
|---|---|
| bool | True if successfully disabled, false otherwise. |
Overrides
Remarks
Removes the NOS power modifier function from the engine's modifier list, preventing the module from affecting engine power output.
VC_Enable(bool)
Enables the NOS module and registers the power modifier with the engine.
Declaration
public override bool VC_Enable(bool calledByParent)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | calledByParent | True if called by parent component, false otherwise. |
Returns
| Type | Description |
|---|---|
| bool | True if successfully enabled, false otherwise. |
Overrides
Remarks
Adds the NOS power modifier function to the engine's modifier list, allowing the module to influence engine power output when active.
VC_Initialize()
Initializes the NOS module and registers the sound component.
Declaration
protected override void VC_Initialize()
Overrides
Remarks
Called once when the module is first initialized. Sets up the NOS sound component and integrates it with the vehicle's sound system.
VC_SetDefaults()
Sets default values for the NOS module and its sound component.
Declaration
public override void VC_SetDefaults()
Overrides
Remarks
Called during initialization to establish default configuration values. Ensures the sound component is properly configured with default settings.