Class EngineFanComponent
Simulates cooling fan or air induction noise that varies with engine RPM. Volume increases quadratically with RPM to simulate fan speed, while pitch increases linearly. Commonly used for commercial vehicles, off-road vehicles with clutch-driven fans, or to add air intake/induction noise to the engine sound.
Inherited Members
Namespace: NWH.VehiclePhysics2.Sound.SoundComponents
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class EngineFanComponent : SoundComponent
Fields
basePitch
Base pitch value at idle RPM. The final pitch is calculated as basePitch + (pitchRange * RPM percentage).
Declaration
[Tooltip("Starting sound pitch at idle RPM.")]
public float basePitch
Field Value
| Type | Description |
|---|---|
| float |
pitchRange
Additional pitch added at maximum RPM. At redline, the pitch will be basePitch + pitchRange. Lower values (0.2-0.5) suit cooling fans, higher values (1-2) work better for induction noise.
Declaration
[Range(0, 4)]
[Tooltip("Pitch range, redline pitch equals basePitch + pitchRange.")]
public float pitchRange
Field Value
| Type | Description |
|---|---|
| float |
Properties
AudioMixerGroup
Gets the Audio Mixer Group this component's AudioSource should output to. Used to route audio through the vehicle's audio mixer for processing and mixing.
Declaration
public override AudioMixerGroup AudioMixerGroup { get; }
Property Value
| Type | Description |
|---|---|
| AudioMixerGroup |
Overrides
ContainerGO
Gets the GameObject container where the AudioSource should be created. Used to position audio sources at specific locations on the vehicle.
Declaration
public override GameObject ContainerGO { get; }
Property Value
| Type | Description |
|---|---|
| GameObject |
Overrides
InitLoop
Gets whether the AudioSource should loop continuously. Override in derived classes to enable looping for continuous sounds like engine running.
Declaration
public override bool InitLoop { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
Priority
Gets the priority level for the AudioSource. Lower values indicate higher priority. Range is 0 (highest) to 256 (lowest). Used by Unity's audio system when the maximum number of audio sources is reached.
Declaration
public override int Priority { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
Methods
VC_Disable(bool)
Stops and disables the AudioSource belonging to this SoundComponent.
Declaration
public override bool VC_Disable(bool calledByParent)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | calledByParent |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
VC_Enable(bool)
Enables the AudioSource belonging to this SoundComponent.
Declaration
public override bool VC_Enable(bool calledByParent)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | calledByParent |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
VC_SetDefaults()
Writes default values into every serialized field, and may pull default assets from Resources. Runs on vehicle reset and when the component is first added.
Declaration
public override void VC_SetDefaults()
Overrides
VC_Update(float)
Per-frame update for input, visuals and UI. Only called while the component is active. Physics belongs in VC_FixedUpdate, not here.
Declaration
public override void VC_Update(float DeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | DeltaTime | Time elapsed since last Update in seconds |