NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class AerodynamicsModule

    Simulates aerodynamic drag and downforce forces on the vehicle.

    Inheritance
    object
    VehicleComponent
    AerodynamicsModule
    Inherited Members
    VehicleComponent.state
    VehicleComponent.vehicleController
    VehicleComponent.IsActive
    VehicleComponent.VC_Initialize(VehicleController)
    VehicleComponent.VC_SetDefaults()
    VehicleComponent.VC_LoadStateFromStateSettings()
    VehicleComponent.VC_Update(float)
    VehicleComponent.VC_Enable(bool)
    VehicleComponent.VC_Disable(bool)
    VehicleComponent.VC_Validate(VehicleController)
    VehicleComponent.UpdateLOD()
    VehicleComponent.ToggleState()
    Namespace: NWH.VehiclePhysics2.Modules.Aerodynamics
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    [Serializable]
    public class AerodynamicsModule : VehicleComponent
    Remarks

    The AerodynamicsModule calculates and applies realistic aerodynamic forces based on vehicle dimensions, speed, and drag coefficients. This affects vehicle behavior at all speeds but becomes increasingly significant as velocity increases.

    Drag Forces: Drag is calculated separately for longitudinal (forward/backward) and lateral (side-to-side) motion using the standard aerodynamic drag equation: F = 0.5 * rho * A * Cd * v^2, where: - rho: Air density (1.225 kg/m³ at sea level) - A: Frontal or side area (calculated from vehicle dimensions) - Cd: Drag coefficient (frontalCd or sideCd) - v: Velocity in the respective direction

    The quadratic relationship means drag increases dramatically at high speeds. For example, doubling speed results in 4x the drag force, creating natural speed limitations.

    Downforce: Downforce can be applied at multiple points on the vehicle to increase tire grip at high speeds. This is particularly useful for race cars and high-performance vehicles. Downforce increases quadratically from 0 to the configured maximum downforce speed, then remains constant beyond that. Position downforce points low on the vehicle (near wheel height) to avoid destabilizing pitch effects.

    Damage Integration: The module integrates with the vehicle's damage system. When damaged, additional drag is applied to simulate compromised aerodynamics from bent panels, broken spoilers, etc. This creates a tangible performance penalty for vehicle damage.

    For more information visit: https://nwhcoding.com/VehiclePhysics/manual/AerodynamicsModule.html

    Fields

    RHO

    Air density constant in kg/m³ at sea level and 15°C. Used in aerodynamic force calculations.

    Declaration
    public const float RHO = 1.225
    Field Value
    Type Description
    float

    damageDragEffect

    Additional drag multiplier applied when the vehicle is fully damaged.

    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
    Remarks

    Simulates the aerodynamic penalty from damaged bodywork, broken spoilers, and compromised aero components. A value of 0.5 means the vehicle experiences 50% additional drag on top of the original undamaged drag value when fully damaged. Partial damage scales linearly.

    Recommended values: - 0.0-0.2: Minor aerodynamic penalty (scratches, minor dents) - 0.3-0.5: Moderate performance loss (default: 0.5) - 0.6-1.0: Significant drag increase (severe damage, missing panels)

    downforcePoints

    List of points on the vehicle where downforce will be applied.

    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

    Each point defines a location and maximum force value. Downforce at each point increases quadratically with speed up to maxDownforceSpeed. Multiple points allow distributing downforce to tune handling balance (understeer/oversteer).

    Positioning Guidelines: - Place points low on the vehicle (near wheel height or floor level) - Avoid high positions that create excessive pitch moments - Typical configuration: One point at front axle, one at rear axle - Front-biased downforce reduces understeer at speed - Rear-biased downforce reduces oversteer and improves stability

    Visible as red sphere gizmos in the Scene view when module is selected.

    frontalCd

    Coefficient of drag (Cd) for the vehicle's frontal area.

    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

    Applied to forward and reverse motion. Lower values reduce drag and improve top speed and acceleration, while higher values increase air resistance.

    Real-world reference values: - Sports cars: 0.25-0.35 - Sedans: 0.3-0.4 - SUVs/Trucks: 0.35-0.5 - Buses/Large vehicles: 0.6-0.8

    The frontal area is automatically calculated from vehicle dimensions as: width * height * 0.85 (accounting for rounded edges and ground clearance).

    maxDownforceSpeed

    Speed in m/s at which downforce reaches its maximum configured value.

    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
    Remarks

    Downforce increases quadratically from 0 to this speed, then remains constant above it. Lower values make downforce more effective at lower speeds, which is useful for circuit racing where top speeds may be limited.

    Recommended values: - Street cars: 50-80 m/s (180-288 km/h) - Race cars: 40-60 m/s (144-216 km/h) - High-speed cars: 80-100 m/s (288-360 km/h)

    Set this based on the typical top speed of your vehicle. As a rule of thumb, set it to 80-90% of maximum achievable speed.

    sideCd

    Coefficient of drag (Cd) for the vehicle's side profile.

    Declaration
    [Range(0, 2)]
    [Tooltip("Coefficient of drag of the vehicle's side profile.")]
    public float sideCd
    Field Value
    Type Description
    float
    Remarks

    Affects resistance to lateral movement (sideways sliding, drifting, crosswinds). Typically higher than frontal Cd due to the less aerodynamic side profile.

    Higher values increase: - Stability in crosswinds - Resistance to drifting and sliding - Cornering grip feel (via reduced slip velocity)

    Lower values allow: - Easier drifting - More responsive to lateral forces - More susceptible to crosswinds

    Typical values: 0.8-1.5 for most vehicles. The side area is automatically calculated from vehicle dimensions as: height * length * 0.8.

    simulateDownforce

    Enables downforce calculation and application.

    Declaration
    [Tooltip("Should downforce be calculated?")]
    public bool simulateDownforce
    Field Value
    Type Description
    bool
    Remarks

    Enable for race cars and high-performance vehicles where aerodynamic grip is important. Disable for regular road vehicles to save computation and avoid unrealistic behavior. When disabled, downforce points are ignored.

    simulateDrag

    Enables aerodynamic drag calculation.

    Declaration
    [Tooltip("Should drag be calculated?")]
    public bool simulateDrag
    Field Value
    Type Description
    bool
    Remarks

    Should generally be enabled for realistic vehicle behavior. Disabling removes air resistance, which will result in unrealistically high top speeds and lack of deceleration when coasting. Only disable for arcade-style games or debugging purposes.

    Methods

    VC_DrawGizmos()

    Draws debug gizmos in the Scene view when the vehicle is selected. Override to visualize component-specific debug information.

    Declaration
    public override void VC_DrawGizmos()
    Overrides
    VehicleComponent.VC_DrawGizmos()
    Remarks

    Only called in Editor when the component is enabled. Use Gizmos and Handles API to draw debug visualizations.

    VC_FixedUpdate(float)

    Physics update called at fixed intervals. Override to implement physics-based behavior.

    Declaration
    public override void VC_FixedUpdate(float DeltaTime)
    Parameters
    Type Name Description
    float DeltaTime

    Time elapsed since last FixedUpdate in seconds

    Overrides
    VehicleComponent.VC_FixedUpdate(float)
    Remarks

    Only called when the component is active (initialized and enabled). Use for physics calculations, force application, and other fixed-timestep operations. Called from VehicleController.FixedUpdate().

    VC_Initialize()

    Initializes the component's internal systems and resources. Called once during vehicle startup after the VehicleController reference is set.

    Declaration
    protected override void VC_Initialize()
    Overrides
    VehicleComponent.VC_Initialize()
    Remarks

    Override this to set up component-specific resources, cache references, or perform one-time initialization. Sets state.initialized to true on completion.

    See Also

    DownforcePoint
    ModuleManager
    VehicleController
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics