NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class SpeedLimiterModule

    Limits maximum vehicle speed by controlling engine power.

    Inheritance
    object
    VehicleComponent
    SpeedLimiterModule
    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.SpeedLimiter
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    [Serializable]
    public class SpeedLimiterModule : VehicleComponent
    Remarks

    Registers a power modifier on the engine and rolls power off linearly over rollOffBand below the limit, reaching 0 at the limit. No brakes are applied, so the vehicle coasts down on drag and gravity can still push it past the limit downhill. Absolute speed, so it holds in reverse too, and it can be toggled at runtime.

    Fields

    active

    Indicates whether the speed limiter is currently limiting power.

    Declaration
    public bool active
    Field Value
    Type Description
    bool
    Remarks

    True whenever the power multiplier is below 1, i.e. anywhere inside rollOffBand below the limit, not only at or above it. Stays true for a decoupled ICE (neutral or open clutch), where the limiter reports active but returns full power so the idle governor is left alone. Only written from the engine power-modifier callback, so it holds its last value while the engine is not running.

    rollOffBand

    Width (m/s) of the band below the limit over which engine power is rolled off to zero.

    Declaration
    [Tooltip("Speed band below the limit over which engine power is rolled off. Always in m/s.")]
    public float rollOffBand
    Field Value
    Type Description
    float
    Remarks

    A band gives the limiter a stable equilibrium. Cutting power outright at the limit makes it a relay: torque toggles on and off at the physics rate and the driveline rings. The vehicle settles slightly below the limit, where the remaining power matches drag.

    speedLimit

    Maximum allowed speed before the limiter cuts engine power.

    Declaration
    [Tooltip("Speed limit above which the throttle will be cut.")]
    public float speedLimit
    Field Value
    Type Description
    float
    Remarks

    Read in the unit named by speedUnits. 0 turns the limiter off entirely. Typical km/h figures: 90-110 delivery vans, 80-100 buses, 40-60 construction vehicles.

    speedUnits

    Unit of measurement for the speedLimit value.

    Declaration
    [Tooltip("Units which will be used for speed limiter. Defaults to m/s.")]
    public SpeedLimiterModule.SpeedUnits speedUnits
    Field Value
    Type Description
    SpeedLimiterModule.SpeedUnits

    Methods

    SpeedPowerLimiter(float)

    Power modifier callback that restricts engine power when speed limit is exceeded.

    Declaration
    public float SpeedPowerLimiter(float DeltaTime)
    Parameters
    Type Name Description
    float DeltaTime

    Time step for the current frame (unused in this modifier).

    Returns
    Type Description
    float

    Power multiplier in [0, 1], rolling off linearly over rollOffBand below the limit.

    Remarks

    Runs once per physics frame as an engine power modifier. The limit is converted to m/s on every call, so changing speedLimit or speedUnits at runtime takes effect immediately.

    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.

    See Also

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