NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class FlipOverModule

    Detects and corrects vehicle rollovers via automatic or manual recovery. Instant mode teleports upright immediately; Gradual mode uses physics-based rotation. Only activates when angle exceeds threshold, velocity is low, and the check interval comes around.

    Inheritance
    object
    VehicleComponent
    FlipOverModule
    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_Update(float)
    VehicleComponent.VC_DrawGizmos()
    VehicleComponent.VC_Validate(VehicleController)
    VehicleComponent.UpdateLOD()
    VehicleComponent.ToggleState()
    Namespace: NWH.VehiclePhysics2.Modules.FlipOver
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    [Serializable]
    public class FlipOverModule : VehicleComponent

    Fields

    allowedAngle

    Minimum angle from upright position (in degrees) required to trigger flip detection.

    Declaration
    [Tooltip("Minimum angle that the vehicle needs to be at for it to be detected as flipped over.")]
    public float allowedAngle
    Field Value
    Type Description
    float
    Remarks

    Angle between the vehicle up vector and the opposite of gravity. Low values catch a rollover early but also fire on steep banking, hillclimbs and two-wheel driving. 45-60° is aggressive, 70-80° balanced, 90-120° only fires when clearly inverted; use 80-90° off-road and 100-120° for stunt vehicles.

    flipOverActivation

    Determines when flip-over recovery is activated.

    Declaration
    public FlipOverModule.FlipOverActivation flipOverActivation
    Field Value
    Type Description
    FlipOverModule.FlipOverActivation
    Remarks
    • Manual: Player must press the flip-over input ('M' with the shipped keyboard providers) to recover
    • Automatic: Recovery begins automatically after timeout when flipped

    flipOverDuration

    Gradual flip animation duration in seconds. Only for Gradual mode. 2-3s: quick (arcade), 4-6s: balanced (default: 5), 7-10s: realistic (sim).

    Declaration
    [Tooltip("How long the flip over process will take if using gradual flip over.")]
    public float flipOverDuration
    Field Value
    Type Description
    float

    flipOverType

    Instant: teleport upright immediately (arcade). Gradual: smooth physics rotation (sim).

    Declaration
    [Tooltip("Determines how the vehicle will be flipped over.")]
    public FlipOverModule.FlipOverType flipOverType
    Field Value
    Type Description
    FlipOverModule.FlipOverType

    flippedOver

    True when angle > allowedAngle and both speeds are below their detection thresholds. Can be used to display UI prompts or trigger other systems.

    Declaration
    [Tooltip("Is the vehicle flipped over?")]
    public bool flippedOver
    Field Value
    Type Description
    bool

    instantFlipOverVerticalOffset

    Vertical offset (m) added during Instant flip to prevent ground clipping. Small vehicles: 0.5-1m. Standard cars: 1-2m (default: 1). Large vehicles: 2-3m. Set to ~half vehicle height. Not used for Gradual mode.

    Declaration
    [Tooltip("If using instant (not gradual) flip over this value will be applied to the transform.y position to prevent rotating\r\nthe object to a position that is underground.")]
    public float instantFlipOverVerticalOffset
    Field Value
    Type Description
    float

    maxDetectionAngularSpeed

    Angular speed threshold (rad/s) for flip detection. The vehicle must be rotating slower than this to be considered settled. 0.6 rad/s is about 34 deg/s.

    Declaration
    [Tooltip("Flip over detection will be disabled if angular velocity is above this value [rad/s].")]
    public float maxDetectionAngularSpeed
    Field Value
    Type Description
    float

    maxDetectionSpeed

    Linear speed threshold (m/s) for flip detection. Tested against the full velocity magnitude, so a vehicle sliding sideways or falling does not pass. 0.2-0.5: strict (sim), 0.6-1.0: balanced (default: 0.6), 1.5-3.0: lenient (arcade).

    Declaration
    [Tooltip("Flip over detection will be disabled if speed is above this value [m/s].")]
    public float maxDetectionSpeed
    Field Value
    Type Description
    float

    timeout

    Interval between flip over checks, in seconds.

    Declaration
    [Tooltip("Interval between flip over checks and the minimum spacing between recovery attempts [s].")]
    public float timeout
    Field Value
    Type Description
    float
    Remarks

    Detection lags the vehicle settling by up to one interval, which leaves the player room to self-recover, and it doubles as the cooldown on manual activation so the flip input cannot be spammed. flippedOver only refreshes once per interval, so a UI prompt reacts no faster. 0.5-1 s is arcade-quick, 1.5-3 s balanced, 3-5 s sim.

    Methods

    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.

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