Class WheelControllerManager
Centralized physics manager for high-frequency wheel substepping. Runs N substeps per FixedUpdate to improve wheel physics stability.
Namespace: NWH.WheelController3D
Assembly: NWH.WheelController.dll
Syntax
[DefaultExecutionOrder(110)]
public class WheelControllerManager : MonoBehaviour
Fields
| Edit this page View SourceFixedDeltaTime
Frame physics timestep (cached Time.fixedDeltaTime).
Declaration
public static float FixedDeltaTime
Field Value
| Type | Description |
|---|---|
| float |
Gravity
Physics.gravity cached for the current FixedUpdate. Constant within a tick, so wheels read this instead of the native property to skip a per-wheel-per-substep read and magnitude sqrt.
Declaration
public static Vector3 Gravity
Field Value
| Type | Description |
|---|---|
| Vector3 |
GravityMagnitude
Magnitude of Gravity, cached per FixedUpdate.
Declaration
public static float GravityMagnitude
Field Value
| Type | Description |
|---|---|
| float |
currentSubstep
Current substep index within the current FixedUpdate (0 to substepCount-1).
Declaration
public static int currentSubstep
Field Value
| Type | Description |
|---|---|
| int |
physicsFrameCount
Global physics tick counter for synchronization.
Declaration
public static int physicsFrameCount
Field Value
| Type | Description |
|---|---|
| int |
substepCount
Current number of substeps (computed from targetEffectiveRate and fixedDeltaTime).
Declaration
[NonSerialized]
public int substepCount
Field Value
| Type | Description |
|---|---|
| int |
substepDeltaTime
Current substep delta time.
Declaration
public static float substepDeltaTime
Field Value
| Type | Description |
|---|---|
| float |
targetEffectiveRate
Target effective physics rate in Hz. Substeps are computed automatically. E.g., 200Hz target at 50Hz physics = 4 substeps.
Declaration
[Tooltip("Target effective physics rate. Substeps are auto-calculated based on fixedDeltaTime.")]
public float targetEffectiveRate
Field Value
| Type | Description |
|---|---|
| float |
Properties
| Edit this page View SourceInstance
Singleton instance. Auto-creates if not present.
Declaration
public static WheelControllerManager Instance { get; }
Property Value
| Type | Description |
|---|---|
| WheelControllerManager |
Methods
| Edit this page View SourceBreakAllStaticFriction(Rigidbody, bool)
Force static friction break on all wheels of a rigidbody group. Used for both vehicles that have one wheel wake up which means we want to wake the rest up, as well as vehicle trailers that need to wake when the vehicle wakes.
Declaration
public void BreakAllStaticFriction(Rigidbody rb, bool clearFilterHistory = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Rigidbody | rb | |
| bool | clearFilterHistory |
Deregister(WheelController)
Deregister a wheel from the physics manager.
Declaration
public void Deregister(WheelController wheel)
Parameters
| Type | Name | Description |
|---|---|---|
| WheelController | wheel |
GetGroup(Rigidbody)
Get the rigidbody group for a specific rigidbody.
Declaration
public WheelControllerGroup GetGroup(Rigidbody rb)
Parameters
| Type | Name | Description |
|---|---|---|
| Rigidbody | rb |
Returns
| Type | Description |
|---|---|
| WheelControllerGroup |
Register(WheelController)
Register a wheel with the physics manager.
Declaration
public void Register(WheelController wheel)
Parameters
| Type | Name | Description |
|---|---|---|
| WheelController | wheel |