Class AerodynamicsModule
Aerodynamic drag and downforce. Drag runs separately on the longitudinal and lateral axes as F = 0.5 * rho * A * Cd * v^2, with the areas derived from vehicleController.dimensions. Downforce is applied at the configured points and scales quadratically up to maxDownforceSpeed.
Inherited Members
Namespace: NWH.VehiclePhysics2.Modules.Aerodynamics
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class AerodynamicsModule : VehicleComponent
Remarks
A DamageHandler on the vehicle scales drag by 1 + damageDragEffect * damage. See https://nwhcoding.com/VehiclePhysics/manual/AerodynamicsModule.html
Fields
RHO
Air density in kg/m³ at sea level and 15°C.
Declaration
public const float RHO = 1.225
Field Value
| Type | Description |
|---|---|
| float |
damageDragEffect
Extra drag at full damage. 0.5 is +50% on top of the undamaged value; partial damage scales linearly. Requires a DamageHandler on the vehicle.
Declaration
[Range(0, 5)]
[Tooltip("The amount of drag that will be added when the vehicle is fully damaged.\r\n0.5 equals +50% on top of the original, undamaged, drag value.")]
public float damageDragEffect
Field Value
| Type | Description |
|---|---|
| float |
downforcePoints
Points at which downforce is applied, each with a local position and a maximum force. Drawn as red sphere gizmos while the vehicle is selected.
Declaration
[Tooltip("Points at which downforce will be applied.\r\nAvoid applying force at too high positions as that will negatively influence suspension and steering.")]
public List<DownforcePoint> downforcePoints
Field Value
| Type | Description |
|---|---|
| List<DownforcePoint> |
Remarks
Keep the positions near wheel height. A high point turns downforce into a pitch moment and upsets suspension and steering.
frontalCd
Drag coefficient of the frontal profile, used for forward and reverse motion.
Declaration
[Range(0, 1)]
[Tooltip("Coefficient of drag of the vehicle's frontal profile.\r\nAlso used for reverse.")]
public float frontalCd
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Frontal area is derived as dimensions.x * dimensions.y * 0.85, the 0.85 covering rounded edges and ground clearance.
maxDownforceSpeed
Speed in m/s at which each downforce point reaches its maxForce. Downforce ramps quadratically up to here and is constant above it. Roughly 80-90% of the vehicle's top speed.
Declaration
[Tooltip("Speed in [m/s] at which the downforce will reach it's maximum value\r\nassigned under downforce points settings.")]
public float maxDownforceSpeed
Field Value
| Type | Description |
|---|---|
| float |
sideCd
Drag coefficient of the side profile, resisting sideways motion. Usually higher than frontalCd; 0.8 to 1.5 covers most vehicles.
Declaration
[Range(0, 2)]
[Tooltip("Coefficient of drag of the vehicle's side profile.")]
public float sideCd
Field Value
| Type | Description |
|---|---|
| float |
Remarks
Side area is derived as dimensions.y * dimensions.z * 0.8.
simulateDownforce
Applies downforce at the configured points. Off means downforcePoints are ignored.
Declaration
[Tooltip("Should downforce be calculated?")]
public bool simulateDownforce
Field Value
| Type | Description |
|---|---|
| bool |
simulateDrag
Applies aerodynamic drag. Off removes air resistance entirely, so top speed climbs and coasting no longer decelerates.
Declaration
[Tooltip("Should drag be calculated?")]
public bool simulateDrag
Field Value
| Type | Description |
|---|---|
| bool |
Methods
VC_DrawGizmos()
Draws component gizmos in the Scene view while the vehicle is selected. Editor only, and only while the component is enabled.
Declaration
public override void VC_DrawGizmos()
Overrides
VC_FixedUpdate(float)
Fixed-timestep update for forces, torques and other physics work. Called from VehicleController.FixedUpdate(), and only while the component is active.
Declaration
public override void VC_FixedUpdate(float DeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | DeltaTime | Time elapsed since last FixedUpdate in seconds |
Overrides
VC_Initialize()
One-time setup, once per vehicle startup and after the VehicleController reference is set. Sets state.initialized on completion; an override that fails must leave it false.
Declaration
protected override void VC_Initialize()
Overrides
VC_Validate(VehicleController)
Editor-side configuration check: null references, out-of-range values, missing dependencies. Reports through Debug.LogWarning/LogError.
Declaration
public override void VC_Validate(VehicleController vc)
Parameters
| Type | Name | Description |
|---|---|---|
| VehicleController | vc | Parent VehicleController to validate against |