NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class LightsManager

    Manages all vehicle lights including headlights, brake lights, turn signals, and auxiliary lighting.

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

    Tail lights follow the low beams, and high beam turns the low beams on with it. Brake lights take priority over tail lights, which usually share the housing. Left and right blinkers are mutually exclusive; hazards override both and flash them together. GetIntState and SetStateFromInt pack the 8 light types one per bit for network sync.

    Fields

    brakeLights

    Rear brake lights, on while braking. Red, and brighter than the tail lights they usually share a housing with.

    Declaration
    [FormerlySerializedAs("stopLights")]
    [Tooltip("Rear lights that will light up when the brake is pressed. Always red.")]
    public VehicleLight brakeLights
    Field Value
    Type Description
    VehicleLight

    extraLights

    Extra lights for special purposes such as fog lights, beacons, light bars, or decorative lighting. Toggled via input and does not interact with other light systems.

    Declaration
    [Tooltip("Can be used for any type of special lights, e.g., beacons.")]
    public VehicleLight extraLights
    Field Value
    Type Description
    VehicleLight

    highBeamLights

    High beam headlights. Turning them on also turns on the low beams and the tail lights.

    Declaration
    [FormerlySerializedAs("fullBeams")]
    [Tooltip("High (full) beam lights.")]
    public VehicleLight highBeamLights
    Field Value
    Type Description
    VehicleLight

    leftBlinkers

    Left turn signals. Flash once per second (0.5 s on, 0.5 s off). Turning them on turns the right blinkers off; hazards override both.

    Declaration
    [Tooltip("Blinkers on the left side of the vehicle.")]
    public VehicleLight leftBlinkers
    Field Value
    Type Description
    VehicleLight

    lowBeamLights

    Low beam headlights. Turning them on also turns on the tail lights.

    Declaration
    [FormerlySerializedAs("headLights")]
    [Tooltip("Low-beam lights.")]
    public VehicleLight lowBeamLights
    Field Value
    Type Description
    VehicleLight

    reverseLights

    Rear reverse lights, driven straight off a negative transmission gear. Usually white.

    Declaration
    [Tooltip("Rear Lights that will light up when the vehicle is in reverse gear(s). Usually white.")]
    public VehicleLight reverseLights
    Field Value
    Type Description
    VehicleLight

    rightBlinkers

    Right turn signals. Flash once per second (0.5 s on, 0.5 s off). Turning them on turns the left blinkers off; hazards override both.

    Declaration
    [Tooltip("Blinkers on the right side of the vehicle.")]
    public VehicleLight rightBlinkers
    Field Value
    Type Description
    VehicleLight

    tailLights

    Rear tail lights, on whenever a beam light is. Red, dimmer than the brake lights.

    Declaration
    [FormerlySerializedAs("rearLights")]
    [Tooltip("Rear Lights that will light up when headlights are on. Always red.")]
    public VehicleLight tailLights
    Field Value
    Type Description
    VehicleLight

    Properties

    LeftBlinkerState

    Free-running blink phase: true for 0.5 s, then false for 0.5 s (one blink per second). Does not include whether the left indicator is enabled - AND it with the blinker input, as VC_Update does.

    Declaration
    public bool LeftBlinkerState { get; }
    Property Value
    Type Description
    bool

    RightBlinkerState

    Free-running blink phase: true for 0.5 s, then false for 0.5 s (one blink per second). Does not include whether the right indicator is enabled - AND it with the blinker input, as VC_Update does.

    Declaration
    public bool RightBlinkerState { get; }
    Property Value
    Type Description
    bool

    Methods

    GetIntState()

    Serializes all light states into a single integer with each bit representing one light type. The 8 light types are packed into bits 0-7 (brake, tail, reverse, low beam, high beam, left blinker, right blinker, extra).

    Declaration
    public int GetIntState()
    Returns
    Type Description
    int

    Integer with bit flags representing the on/off state of each light type.

    SetStateFromInt(int)

    Deserializes light states from a single integer where each bit represents one light type. Should be called with values obtained from GetIntState() on another instance.

    Declaration
    public void SetStateFromInt(int intState)
    Parameters
    Type Name Description
    int intState

    Integer with bit flags representing the desired on/off state of each light type.

    TurnOffAllLights()

    Turns off all lights and emission on all meshes.

    Declaration
    public void TurnOffAllLights()

    VC_Disable(bool)

    Disables the component and stops its updates.

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

    True when called by a parent ManagerVehicleComponent fan-out or the VehicleController enable/disable loop. The LOD system passes false.

    Returns
    Type Description
    bool

    True if successfully disabled, false otherwise

    Overrides
    VehicleComponent.VC_Disable(bool)
    Remarks

    Refused on a component that is not initialized. Records whether the call came from a parent, which is what VC_Enable checks before a bulk re-enable.

    VC_Enable(bool)

    Enables the component and starts its updates.

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

    True when called by a parent ManagerVehicleComponent fan-out or the VehicleController enable/disable loop. The LOD system passes false.

    Returns
    Type Description
    bool

    True if successfully enabled, false otherwise

    Overrides
    VehicleComponent.VC_Enable(bool)
    Remarks

    Initializes the component first if it is not initialized yet. A parent bulk enable is refused unless the last disable also came from a parent, so it cannot resurrect a component turned off by LOD, by a script, or disabled in StateSettings.

    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

    Overrides
    VehicleComponent.VC_Update(float)
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics