Class TransmissionComponent
Gearbox between the clutch and the differential or wheels. Holds the gear ratios and the shift logic for Manual, Automatic, AutomaticSequential, CVT and External types.
Inherited Members
Namespace: NWH.VehiclePhysics2.Powertrain
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class TransmissionComponent : PowertrainComponent
Remarks
Works together with the clutch: the automatic and CVT paths drive clutch engagement themselves, manual needs driver input or an external clutch. shiftDuration and the shift points set how the box feels, from a slow torque-converter shift to a hard sequential one.
Fields
allowDownshiftGearSkipping
Lets an automatic drop several gears at once under heavy braking, 5th straight to 2nd. Worth it on trucks and high-gear-count vehicles. No effect in sequential or manual.
Declaration
public bool allowDownshiftGearSkipping
Field Value
| Type | Description |
|---|---|
| bool |
allowUpshiftGearSkipping
Lets an automatic climb several gears at once on light throttle, 2nd straight to 4th. No effect in sequential or manual.
Declaration
public bool allowUpshiftGearSkipping
Field Value
| Type | Description |
|---|---|
| bool |
automaticTransmissionDNRShiftType
Behavior when switching from neutral to forward or reverse gear.
Declaration
[FormerlySerializedAs("automaticTransmissionReverseType")]
[FormerlySerializedAs("reverseType")]
[Tooltip("Behavior when switching from neutral to forward or reverse gear.")]
public TransmissionComponent.AutomaticTransmissionDNRShiftType automaticTransmissionDNRShiftType
Field Value
| Type | Description |
|---|---|
| TransmissionComponent.AutomaticTransmissionDNRShiftType |
clutchInputShiftThreshold
Maximum clutch engagement allowed for manual shifts. Set to 1 to disable clutch shift gating.
Declaration
[Tooltip("Maximum clutch engagement allowed for manual shifts. Set to 1 to disable clutch shift gating.")]
public float clutchInputShiftThreshold
Field Value
| Type | Description |
|---|---|
| float |
currentGearRatio
Current gear ratio.
Declaration
[Tooltip("Current gear ratio.")]
[ShowInTelemetry(NaN, NaN, null, null, 1)]
public float currentGearRatio
Field Value
| Type | Description |
|---|---|
| float |
cvtResponseRate
How fast the CVT ratio moves toward its target. Higher is more responsive.
Declaration
[Range(1, 20)]
[Tooltip("How quickly the CVT ratio adjusts (1-20). Higher = faster response.")]
public float cvtResponseRate
Field Value
| Type | Description |
|---|---|
| float |
cvtTargetRPMPercent
Engine RPM fraction (0-1) the CVT holds. Lower is economical, higher is quicker.
Declaration
[Range(0.3, 0.9)]
[Tooltip("Target engine RPM percent (0-1) the CVT will try to maintain. Lower = efficiency, higher = performance.")]
public float cvtTargetRPMPercent
Field Value
| Type | Description |
|---|---|
| float |
damageShiftDurationMultiplier
Maximum shift duration multiplier at full damage. 3 = 3x longer shifts at damage=1.
Declaration
[Range(1, 5)]
[Tooltip("Maximum shift duration multiplier at full damage. 3 = 3x longer shifts when damage=1.")]
public float damageShiftDurationMultiplier
Field Value
| Type | Description |
|---|---|
| float |
dnrSpeedThreshold
Speed at which the vehicle can switch between D/N/R gears.
Declaration
[Tooltip("Speed at which the vehicle can switch between D/N/R gears.")]
public float dnrSpeedThreshold
Field Value
| Type | Description |
|---|---|
| float |
finalGearRatio
Final gear multiplier. Each gear gets multiplied by this value. Equivalent to an axle/differential ratio in real life.
Declaration
[Tooltip(" Final gear multiplier. Each gear gets multiplied by this value.\r\n Equivalent to axle/differential ratio in real life.")]
[ShowInSettings("Final Ratio", 1, 20, 1)]
public float finalGearRatio
Field Value
| Type | Description |
|---|---|
| float |
forwardGearCount
Number of forward gears.
Declaration
[Tooltip("Number of forward gears.")]
public int forwardGearCount
Field Value
| Type | Description |
|---|---|
| int |
gearIndex
Current gear index in the gear list. Different from gear because gear uses -1 = R, 0 = N and D = 1, while this is the absolute index in the range of 0 to gear list size minus one. Use Gear to get the actual gear.
Declaration
[NonSerialized]
[ShowInTelemetry(NaN, NaN, null, null, 1)]
[Tooltip("Current gear index in the gears list.\r\nDifferent from gear because gear uses -1 = R, 0 = N and D = 1, while this is the absolute index\r\nin the range of 0 to gear list size minus one.\r\nUse Gear to get the actual gear.")]
public int gearIndex
Field Value
| Type | Description |
|---|---|
| int |
gears
A list of gear ratios in order of negative, neutral and then positive. E.g., -4, 0, 6, 4, 3, 2. Reverse gears run tallest first: R1 is the negative entry next to neutral, so with several reverse gears their magnitude increases toward neutral, the opposite of the forward gears.
Declaration
[SerializeField]
[Tooltip("A list of gears ratios in order of negative, neutral and then positive.\r\nE.g. -4, 0, 6, 4, 3, 2 => one reverse, 4 forward gears.\r\nReverse gears are listed tallest first - R1 is the entry next to neutral. E.g. -6.5, -8.2, -10.8, 0, 11.7, 9.2 => R1 is -10.8.")]
public List<float> gears
Field Value
| Type | Description |
|---|---|
| List<float> |
holdToKeepInGear
If true, the gear input has to be held for the transmission to stay in gear; otherwise it goes to neutral. Used for hardware H-shifters.
Declaration
[Tooltip("If true the gear input has to be held for the transmission to stay in gear, otherwise it goes to neutral.\r\nUsed for hardware H-shifters.")]
public bool holdToKeepInGear
Field Value
| Type | Description |
|---|---|
| bool |
ignorePostShiftBanInManual
If enabled, manual transmission shifts skip the post-shift ban so the user can shift again immediately.
Declaration
[Tooltip("If enabled, manual transmission shifts skip the post-shift ban so the user can shift again immediately.")]
public bool ignorePostShiftBanInManual
Field Value
| Type | Description |
|---|---|
| bool |
inclineEffectCoeff
How much incline affects shift point position? Higher value will push the shift up and shift down RPM up depending on the current incline to prevent the vehicle from upshifting at the wrong time.
Declaration
[Range(0, 4)]
[Tooltip("How much inclines affect shift point position. Higher value will push the shift up and shift down RPM up depending \r\non the current incline to prevent vehicle from upshifting at the wrong time.")]
public float inclineEffectCoeff
Field Value
| Type | Description |
|---|---|
| float |
isPostShiftBanActive
Is the transmission currently in the post-shift phase in which the shifting is disabled/banned to prevent gear hunting?
Declaration
[Tooltip("Is the transmission currently in the post-shift phase in which the shifting is disabled/banned to prevent gear hunting?")]
public bool isPostShiftBanActive
Field Value
| Type | Description |
|---|---|
| bool |
isSequential
Is the automatic gearbox sequential? Has no effect on manual transmission.
Declaration
[ShowInSettings("Sequential")]
[Tooltip("Is the automatic gearbox sequential?\r\nHas no effect on manual transmission.")]
public bool isSequential
Field Value
| Type | Description |
|---|---|
| bool |
isShifting
Is a gear shift currently in progress.
Declaration
[ShowInTelemetry(NaN, NaN, null, null, 1)]
[Tooltip("Is a gear shift currently in progress.")]
public bool isShifting
Field Value
| Type | Description |
|---|---|
| bool |
onDownshift
Event that gets triggered when transmission shifts down.
Declaration
[SerializeField]
[Tooltip("Event that gets triggered when transmission shifts down.")]
public UnityEvent onDownshift
Field Value
| Type | Description |
|---|---|
| UnityEvent |
onShift
Event that gets triggered when transmission shifts (up or down).
Declaration
[SerializeField]
[Tooltip("Event that gets triggered when transmission shifts (up or down).")]
public UnityEvent onShift
Field Value
| Type | Description |
|---|---|
| UnityEvent |
onUpshift
Event that gets triggered when transmission shifts up.
Declaration
[SerializeField]
[Tooltip("Event that gets triggered when transmission shifts up.")]
public UnityEvent onUpshift
Field Value
| Type | Description |
|---|---|
| UnityEvent |
postShiftBan
Time after shifting in which shifting cannot be done again.
Declaration
[Tooltip("Time after shifting in which shifting cannot be done again.")]
public float postShiftBan
Field Value
| Type | Description |
|---|---|
| float |
referenceShiftRPM
Declaration
[NonSerialized]
public float referenceShiftRPM
Field Value
| Type | Description |
|---|---|
| float |
reverseGearCount
Number of reverse gears.
Declaration
[Tooltip("Number of reverse gears.")]
public int reverseGearCount
Field Value
| Type | Description |
|---|---|
| int |
shiftDelegate
Function that changes the gears as required. Use transmissionType External and assign this delegate to use your own gear shift code.
Declaration
[Tooltip("Function that changes the gears as required.\r\nUse transmissionType External and assign this delegate to use your own gear shift code.")]
public TransmissionComponent.Shift shiftDelegate
Field Value
| Type | Description |
|---|---|
| TransmissionComponent.Shift |
shiftDuration
Time it takes transmission to shift between gears.
Declaration
[ShowInSettings("Shift Duration", 0.001, 0.5, 0.05)]
[Tooltip("Time it takes transmission to shift between gears.")]
public float shiftDuration
Field Value
| Type | Description |
|---|---|
| float |
shiftInAir
Should the transmission shift while the vehicle is fully in the air? All wheels must be off the ground for it to be considered as in air.
Declaration
[Tooltip("Should the transmission shift while the vehicle is fully in air. All wheels must be off the ground for it to be considered as in air.")]
public bool shiftInAir
Field Value
| Type | Description |
|---|---|
| bool |
shiftProgress
Progress of the current gear shift in range of 0 to 1.
Declaration
[Tooltip("Progress of the current gear shift in range of 0 to 1.")]
public float shiftProgress
Field Value
| Type | Description |
|---|---|
| float |
transmissionType
How gears are changed. Manual shifts only on user input. Automatic shifts on its own and can skip gears, 3rd to 5th, which suits trucks and other high-gear-count vehicles. AutomaticSequential shifts on its own but one gear at a time, 3rd to 4th.
Declaration
[SerializeField]
[Tooltip("Manual - gears can only be shifted by manual user input. Automatic - automatic gear changing. Allows for gear skipping (e.g. 3rd->5th) which can be useful in trucks and other high gear count vehicles. AutomaticSequential - automatic gear changing but only one gear at the time can be shifted (e.g. 3rd->4th)")]
[ShowInSettings("Type")]
[FormerlySerializedAs("_transmissionType")]
public TransmissionComponent.TransmissionShiftType transmissionType
Field Value
| Type | Description |
|---|---|
| TransmissionComponent.TransmissionShiftType |
triedToShiftWithoutClutch
Called when the user tries to shift without the clutch input and the clutch shift threshold is below 1.
Declaration
[Tooltip("Called when user tries to shift without clutch input and the clutch shift threshold is below 1.")]
public UnityEvent triedToShiftWithoutClutch
Field Value
| Type | Description |
|---|---|
| UnityEvent |
variableShiftIntensity
How far the shift points drop below their configured RPMs at light throttle. 0 keeps them fixed; higher values shift earlier the lighter the load.
Declaration
[Range(0, 1)]
[Tooltip("How far the shift points drop below their configured RPMs at light throttle. 0 = fixed, higher = earlier shifts when coasting.")]
public float variableShiftIntensity
Field Value
| Type | Description |
|---|---|
| float |
variableShiftPoint
If enabled, transmission will adjust both the shift up and down points to match the current load.
Declaration
[ShowInSettings("Variable Shift Point")]
[Tooltip("If enabled, transmission will adjust both the shift up and down points to match the current load.")]
public bool variableShiftPoint
Field Value
| Type | Description |
|---|---|
| bool |
Properties
DownshiftRPM
Full-load RPM at which the automatic transmission shifts down. With variable shift point on, the live point drops below this at lighter throttle; use TargetDownshiftRPM for the current value.
Declaration
public float DownshiftRPM { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Gear
0 for neutral, less than 0 for reverse gears and larger than 0 for forward gears. Use 'ShiftInto' to set gear.
Declaration
public int Gear { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
GearName
Returns the current gear name as a string, e.g. "R", "R2", "N" or "1"
Declaration
public string GearName { get; }
Property Value
| Type | Description |
|---|---|
| string |
ReferenceShiftRPM
Pre-14.0 name of referenceShiftRPM.
Declaration
[Obsolete("Renamed to referenceShiftRPM.")]
public float ReferenceShiftRPM { get; }
Property Value
| Type | Description |
|---|---|
| float |
TargetDownshiftRPM
Live downshift threshold used for shift decisions, derived from DownshiftRPM scaled by load and adjusted for incline. Equals DownshiftRPM at full throttle.
Declaration
public float TargetDownshiftRPM { get; }
Property Value
| Type | Description |
|---|---|
| float |
TargetUpshiftRPM
Live upshift threshold used for shift decisions, derived from UpshiftRPM scaled by load and adjusted for incline. Equals UpshiftRPM at full throttle.
Declaration
public float TargetUpshiftRPM { get; }
Property Value
| Type | Description |
|---|---|
| float |
UpshiftRPM
Full-load RPM at which the automatic transmission shifts up. With variable shift point on, the live point drops below this at lighter throttle; use TargetUpshiftRPM for the current value.
Declaration
public float UpshiftRPM { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
ForwardStep(float, float, float)
Performs the forward pass of torque transmission through the powertrain chain.
Declaration
public override float ForwardStep(float torque, float inertiaSum, float DeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | torque | The input torque in N⋅m. |
| float | inertiaSum | The accumulated inertia of all upstream components in kg⋅m². |
| float | DeltaTime | The simulation delta time in seconds. |
Returns
| Type | Description |
|---|---|
| float | The final torque after processing through all connected components. |
Overrides
Remarks
Part of solver pass 2: propagates torque from engine toward wheels. Components apply gear ratios, losses, etc. Returns input torque if no output connected. The engine discards this return value and reads QueryReturnTorque() after the wheels have stepped, so QueryReturnTorque() is the live reaction path; a new node must override that one to be felt upstream.
GetGearRatio(int)
Gets the total gear ratio for the specified gear, including final drive ratio.
Declaration
public float GetGearRatio(int g)
Parameters
| Type | Name | Description |
|---|---|---|
| int | g | Gear number (-1 for reverse, 0 for neutral, 1+ for forward gears) |
Returns
| Type | Description |
|---|---|
| float | Combined gear ratio (transmission gear × final drive ratio) |
Remarks
The full input-to-output ratio. Higher multiplies more torque and lowers top speed.
GetWorldPosition(VehicleController)
Gets the world position of the transmission component.
Declaration
public override Vector3 GetWorldPosition(VehicleController vc)
Parameters
| Type | Name | Description |
|---|---|---|
| VehicleController | vc | The vehicle controller. |
Returns
| Type | Description |
|---|---|
| Vector3 | Transmission position in world space. |
Overrides
QueryAngularVelocity(float, float)
Queries and propagates angular velocity through the powertrain chain.
Declaration
public override float QueryAngularVelocity(float angularVelocity, float dt)
Parameters
| Type | Name | Description |
|---|---|---|
| float | angularVelocity | The input angular velocity in rad/s. |
| float | dt | The simulation delta time in seconds. |
Returns
| Type | Description |
|---|---|
| float | The final angular velocity after propagation through all connected components. |
Overrides
Remarks
Part of solver pass 1: propagates angular velocity from wheels toward engine. Returns input velocity unchanged if no output is connected.
QueryInertia(float)
Queries and accumulates inertia values through the powertrain chain.
Declaration
public override float QueryInertia(float DeltaTime)
Parameters
| Type | Name | Description |
|---|---|---|
| float | DeltaTime | The simulation delta time in seconds. |
Returns
| Type | Description |
|---|---|
| float | The total inertia of this component and all connected downstream components in kg⋅m². |
Overrides
Remarks
Adds this component's inertia to downstream components' accumulated inertia. Higher total inertia = slower acceleration, lower = more responsive.
QueryReturnTorque()
Queries the return torque (counterTorque) from downstream components after wheels have been stepped. Called after ForwardStep and wheel SubStep to get fresh counterTorque values.
Declaration
public override float QueryReturnTorque()
Returns
| Type | Description |
|---|---|
| float | The accumulated return torque from all downstream components. |
Overrides
RecalculateGearRatio(float)
Updates currentGearRatio for the substep. Called before engine integration so the query and torque passes share one ratio per substep.
Declaration
public void RecalculateGearRatio(float dt)
Parameters
| Type | Name | Description |
|---|---|---|
| float | dt |
ReverseTransmitRPM(float, int)
Converts axle RPM to engine RPM for the given gear in the Gears list.
Declaration
public float ReverseTransmitRPM(float inputRPM, int g)
Parameters
| Type | Name | Description |
|---|---|---|
| float | inputRPM | |
| int | g |
Returns
| Type | Description |
|---|---|
| float |
ShiftInto(int, bool)
Shifts into given gear. 0 for neutral, less than 0 for reverse and above 0 for forward gears. Does nothing if the target gear is equal to the current gear.
Declaration
public void ShiftInto(int targetGear, bool instant = false)
Parameters
| Type | Name | Description |
|---|---|---|
| int | targetGear | |
| bool | instant |
VC_Disable(bool)
Disables the powertrain component and resets its operational values.
Declaration
public override bool VC_Disable(bool calledByParent)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | calledByParent | True if this method was called by a parent component, false if called directly. |
Returns
| Type | Description |
|---|---|
| bool | True if the component was successfully disabled, false otherwise. |
Overrides
Remarks
Zeroes angular velocity and torque so the next enable starts clean.
VC_Initialize()
Initializes the powertrain component and establishes connections with other components.
Declaration
protected override void VC_Initialize()
Overrides
Remarks
Floors inertia at MIN_INERTIA and resolves the input and output links from persisted names.
VC_SetDefaults()
Sets the component's properties to their default values.
Declaration
public override void VC_SetDefaults()
Overrides
Remarks
Sets inertia to 0.02 kg⋅m², suitable for most powertrain components.
VC_Validate(VehicleController)
Validates the powertrain component configuration and logs warnings for potential issues.
Declaration
public override void VC_Validate(VehicleController vc)
Parameters
| Type | Name | Description |
|---|---|---|
| VehicleController | vc | The vehicle controller that contains this component. |
Overrides
Remarks
Checks inertia minimum (0.0001) and output connections. Called during vehicle validation.