Class WheelComponent
Represents a wheel as a node in the powertrain system. Handles torque application from the powertrain to the wheel, brake torque distribution, and integrates with the WheelController for physics simulation.
Inherited Members
Namespace: NWH.VehiclePhysics2.Powertrain
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class WheelComponent : PowertrainComponent
Fields
surfaceMapIndex
Index of the surface in the active SurfaceMap that the wheel is currently in contact with. -1 if the wheel is not grounded.
Declaration
[NonSerialized]
[ShowInTelemetry(NaN, NaN, null, null, 1)]
public int surfaceMapIndex
Field Value
| Type | Description |
|---|---|
| int |
surfacePreset
The SurfacePreset of the surface the wheel is currently in contact with. Null if the wheel is not grounded.
Declaration
[ShowInTelemetry(NaN, NaN, null, null, 1)]
public SurfacePreset surfacePreset
Field Value
| Type | Description |
|---|---|
| SurfacePreset |
wheelController
Reference to the WheelController that handles the physics simulation for this wheel.
Declaration
public WheelController wheelController
Field Value
| Type | Description |
|---|---|
| WheelController |
wheelGroup
The WheelGroup this wheel belongs to. Set automatically when the wheel is assigned to a group.
Declaration
[NonSerialized]
public WheelGroup wheelGroup
Field Value
| Type | Description |
|---|---|
| WheelGroup |
wheelGroupSelector
Selector for assigning this wheel to a specific WheelGroup. Used in the editor to organize wheels into axles/groups for differential and brake distribution.
Declaration
public WheelGroupSelector wheelGroupSelector
Field Value
| Type | Description |
|---|---|
| WheelGroupSelector |
Methods
AddBrakeTorque(float, bool)
Adds brake torque to the wheel on top of the existing torque. The torque is multiplied by the wheel group's brake coefficient or handbrake coefficient. Final value is clamped to the vehicle's maximum brake torque.
Declaration
public void AddBrakeTorque(float torque, bool isHandbrake = false)
Parameters
| Type | Name | Description |
|---|---|---|
| float | torque | The brake torque to add in Nm. Negative values are ignored. |
| bool | isHandbrake | If true, applies the handbrake coefficient instead of the brake coefficient. |
ApplyRollingResistanceMultiplier(float)
Applies a multiplier to the wheel's rolling resistance torque. Useful for simulating different surface conditions or temporary effects.
Declaration
public void ApplyRollingResistanceMultiplier(float multiplier)
Parameters
| Type | Name | Description |
|---|---|---|
| float | multiplier | The multiplier to apply to the initial rolling resistance. Values greater than 1 increase resistance, less than 1 decrease it. |
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.
GetWorldPosition(VehicleController)
Gets the world position of the wheel component.
Declaration
public override Vector3 GetWorldPosition(VehicleController vc)
Parameters
| Type | Name | Description |
|---|---|---|
| VehicleController | vc | The vehicle controller. |
Returns
| Type | Description |
|---|---|
| Vector3 | Wheel 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
SetWheelGroup(int)
Sets the wheel group index for this wheel component. This determines which WheelGroup the wheel belongs to for brake distribution and differential connections.
Declaration
public void SetWheelGroup(int wheelGroupIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | wheelGroupIndex | The index of the WheelGroup in the powertrain's wheelGroups list. |
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
When disabled, all angular velocity and torque values are reset to zero to ensure a clean state for the next time the component is enabled.
VC_Initialize()
Initializes the powertrain component and establishes connections with other components.
Declaration
protected override void VC_Initialize()
Overrides
Remarks
Called during vehicle initialization. Validates inertia and loads component connections from stored name hashes.
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.