NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class ExhaustFlash

    Controls exhaust flash effects that create brief, bright flame bursts from exhaust pipes during engine operation, gear shifts, and rev limiter engagement.

    Inheritance
    object
    VehicleComponent
    Effect
    ExhaustFlash
    Inherited Members
    VehicleComponent.state
    VehicleComponent.vehicleController
    VehicleComponent.IsActive
    VehicleComponent.VC_Initialize(VehicleController)
    VehicleComponent.VC_Initialize()
    VehicleComponent.VC_FixedUpdate(float)
    VehicleComponent.VC_LoadStateFromStateSettings()
    VehicleComponent.VC_Update(float)
    VehicleComponent.VC_DrawGizmos()
    VehicleComponent.VC_Validate(VehicleController)
    VehicleComponent.UpdateLOD()
    VehicleComponent.ToggleState()
    Namespace: NWH.VehiclePhysics2.Effects
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    [Serializable]
    public class ExhaustFlash : Effect
    Remarks

    ExhaustFlash simulates the dramatic flame effects commonly seen on performance vehicles, particularly during high-performance driving, gear changes, or when the rev limiter is active. The effect is achieved through material color manipulation and optional light flashing.

    Key features include: - Configurable flash probability based on engine conditions - Variable flash duration for different visual effects - Automatic triggering on gear shifts and rev limiter engagement - Support for multiple exhaust flash points - Integration with Unity Light components for illumination effects - Customizable flash intensity and color through materials

    The system modifies material emission properties to create the flash effect, requiring materials with emission-enabled shaders. Flash frequency and intensity scale with engine load and RPM to provide realistic exhaust flame behavior.

    Fields

    flashChance

    Probability of a flash occurring per engine firing cycle (0-1 range). Higher values create more frequent flashing effects.

    Declaration
    public float flashChance
    Field Value
    Type Description
    float
    Remarks

    Low values (0.05-0.1): Occasional subtle flashes, realistic for most engines. Medium values (0.15-0.3): Regular flashing, good for performance vehicles. High values (0.4-0.8): Frequent dramatic flashes, suitable for race cars or backfiring engines.

    flashDuration

    Duration of each flash effect in seconds. Controls how long the flash remains visible before fading out.

    Declaration
    public float flashDuration
    Field Value
    Type Description
    float
    Remarks

    Short duration (0.02-0.05s): Quick, realistic exhaust flames. Medium duration (0.08-0.15s): More visible effects for gameplay feedback. Long duration (0.2s+): Dramatic, unrealistic but visually impressive flashes.

    flashLights

    Optional Unity Light components that will flash in sync with the exhaust flash effect. Used to illuminate surroundings during flash events.

    Declaration
    public List<Light> flashLights
    Field Value
    Type Description
    List<Light>
    Remarks

    Lights provide additional realism by illuminating nearby objects during flashes. Keep light range and intensity moderate to avoid performance issues.

    flashOnRevLimiter

    Enable flashing when the engine hits the rev limiter. Creates dramatic effects during over-revving situations.

    Declaration
    public bool flashOnRevLimiter
    Field Value
    Type Description
    bool

    flashOnShift

    Enable flashing during gear shifts, particularly with aggressive shift patterns. Adds visual feedback for transmission events.

    Declaration
    public bool flashOnShift
    Field Value
    Type Description
    bool

    flashTextures

    Textures representing exhaust flash. If multiple textures are assigned, a random texture will be chosen for each flash.

    Declaration
    [Tooltip("Textures representing exhaust flash. If multiple are assigned a random texture will be chosen for each flash.")]
    public List<Texture2D> flashTextures
    Field Value
    Type Description
    List<Texture2D>

    flashWhenEngineOff

    Allow flashes while the engine is off/idling. Off by default so a dead engine shuffling D/N/R (automatic N↔R) does not spam flashes. Matches the exhaust pop guard.

    Declaration
    public bool flashWhenEngineOff
    Field Value
    Type Description
    bool

    meshRenderers

    Mesh renderer(s) for the exhaust flash meshes.

    Declaration
    [Tooltip("Mesh renderer(s) for the exhaust flash meshes.")]
    public List<MeshRenderer> meshRenderers
    Field Value
    Type Description
    List<MeshRenderer>

    onFlash

    Unity event triggered each time an exhaust flash occurs. Use this to synchronize additional effects like camera shake, sound, or particle systems.

    Declaration
    public UnityEvent onFlash
    Field Value
    Type Description
    UnityEvent
    Remarks

    Called immediately when a flash begins, before the visual flash duration starts. Useful for triggering complementary effects that should accompany exhaust flashes.

    Methods

    Flash(bool)

    Triggers a single flash immediately.

    Declaration
    public void Flash(bool triggerEvent)
    Parameters
    Type Name Description
    bool triggerEvent

    Whether to invoke the onFlash event.

    FlashWithChance()

    Rolls flashChance and flashes if it passes, invoking the onFlash event. Event-driven entry (rev limiter / shift); skips when the engine isn't actually firing unless flashWhenEngineOff.

    Declaration
    public void FlashWithChance()

    FlashWithChance(bool, float)

    Rolls the given chance and flashes if it passes.

    Declaration
    public void FlashWithChance(bool triggerEvent, float chance)
    Parameters
    Type Name Description
    bool triggerEvent

    Whether to invoke the onFlash event.

    float chance

    Flash probability in the 0-1 range.

    VC_Disable(bool)

    Disables the component and stops updates. Override to add component-specific disable logic.

    Declaration
    public override bool VC_Disable(bool calledByParent)
    Parameters
    Type Name Description
    bool calledByParent

    True if called by parent component or LOD system

    Returns
    Type Description
    bool

    True if successfully disabled, false otherwise

    Overrides
    VehicleComponent.VC_Disable(bool)
    Remarks

    Component must be initialized before it can be disabled. Tracks whether disable was called by parent to manage LOD system interaction.

    VC_Enable(bool)

    Enables the component and starts updates. Override to add component-specific enable logic.

    Declaration
    public override bool VC_Enable(bool calledByParent)
    Parameters
    Type Name Description
    bool calledByParent

    True if called by parent component or LOD system

    Returns
    Type Description
    bool

    True if successfully enabled, false otherwise

    Overrides
    VehicleComponent.VC_Enable(bool)
    Remarks

    Will initialize the component if not already initialized. Components disabled by LOD system will track the parent caller to prevent manual enabling while LOD is controlling state.

    VC_SetDefaults()

    Resets the component to default configuration. Override to provide component-specific default values.

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

    Called when the vehicle is reset or when first added to a GameObject. Should set all serialized fields to sensible default values. May load default assets from Resources folder.

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