Skip to main content

Class WheelControl

Bridges Unity's WheelCollider physics with one or more visual wheel meshes, and manages per-wheel steering, motor torque, braking, and drift visual effects.

[RequireComponent(typeof(WheelCollider))]
public class WheelControl : MonoBehaviour

Inheritance​

Remarks​

Each physical WheelCollider requires a separate WheelControl because Unity's wheel physics is per-collider. This component owns the collider and exposes a clean API (SetSteerInput, SetMotorTorque, SetBrakeTorque) so PrometeoCarController does not need to know which wheel meshes exist.

The steeringCurve maps normalised steer input to wheel angle in degrees, allowing non-linear steering response (e.g. reduced sensitivity at centre) without changing the controller code. Smoke and skid-trail effects are activated based on wheel slip, providing perceptual cues about traction loss to participants.

Fields​

SmokeParticleSystem​

Optional smoke particle system used for wheel slip effects.

[Tooltip("Optional smoke particle system used when the wheel slips.")]
public Optional<ParticleSystem> SmokeParticleSystem

Field Value​

Optional<ParticleSystem>

TireSkid​

Optional trail renderer used to draw skid marks.

[Tooltip("Optional trail renderer used to draw tire skid marks.")]
public Optional<TrailRenderer> TireSkid

Field Value​

Optional<TrailRenderer>

WheelCollider​

[NonSerialized]
public WheelCollider WheelCollider

Field Value​

WheelCollider

motorized​

If true, this wheel is motorized (receives motor torque).

[Tooltip("Indicates if this wheel is powered by the motor.")]
public bool motorized

Field Value​

bool

steerable​

If true, this wheel can steer.

[Tooltip("Indicates if this wheel is capable of steering.")]
public bool steerable

Field Value​

bool

Methods​

GetMaxSteeringAngle()​

Returns the maximum angle (in degrees) this wheel can steer to, based on the steering curve.

public float GetMaxSteeringAngle()

Returns​

float

SetBrakeTorque(float)​

Applies brake torque to the WheelCollider.

public void SetBrakeTorque(float brakeTorque)

Parameters​

NameTypeDescription
brakeTorquefloatThe amount of braking force to apply.

SetMotorTorque(float)​

Applies motor torque to the WheelCollider.

public void SetMotorTorque(float motorTorque)

Parameters​

NameTypeDescription
motorTorquefloatThe amount of torque to apply.

SetSmokeParticleActive(bool)​

Activates/Deactivates the wheel's smoke particles, depending on the given true or false value.

public void SetSmokeParticleActive(bool value)

Parameters​

NameTypeDescription
valueboolActivate or deactivate the particles, where true activates the smoke particles and false deactivates the smoke particles.

SetSteerInput(float)​

Sets the steering input for this wheel.

public void SetSteerInput(float input)

Parameters​

NameTypeDescription
inputfloatSteering input from -1 (left) to 1 (right).

SetTireSkidActive(bool)​

Activates/Deactivates the wheel's tire skid trail, depending on the given true or false value, and whethever the wheel collider is on ground.

public void SetTireSkidActive(bool value)

Parameters​

NameTypeDescription
valueboolActivate or deactivate the tire skid, where true activates the tire skid and false deactivates the tire skid.
  • Remarks
  • Fields
    • SmokeParticleSystem
    • TireSkid
    • WheelCollider
    • motorized
    • steerable
  • Methods
    • GetMaxSteeringAngle()
    • SetBrakeTorque(float)
    • SetMotorTorque(float)
    • SetSmokeParticleActive(bool)
    • SetSteerInput(float)
    • SetTireSkidActive(bool)