NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class SteeringWheel

    Interactive touch-based steering wheel UI control for mobile input. Tracks touch/mouse drag input and returns steering values in range [-1, 1]. Automatically returns to center when released. Based on code by yasirkula from Unity Forums.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    SteeringWheel
    Namespace: NWH.VehiclePhysics2.VehicleGUI
    Assembly: NWH.VehiclePhysics2.dll
    Syntax
    public class SteeringWheel : MonoBehaviour

    Fields

    maximumSteeringAngle

    Maximum rotation angle of the steering wheel in degrees (for one side). Real steering wheels typically rotate 450-900 degrees (225-450 per side). Lower values (180-200) provide more arcade-like, sensitive steering. Higher values (400-450) provide more realistic, simulation-style steering.

    Declaration
    [Tooltip("Maximum angle that the steering wheel can be turned to towards either side in degrees.")]
    public float maximumSteeringAngle
    Field Value
    Type Description
    float

    returnToCenterSpeed

    Rotation speed for automatic return-to-center in degrees per second. Higher values make the wheel snap back faster when released. Typical values: 200-600 degrees/second.

    Declaration
    [Tooltip("Speed at which the wheel is returned to center in degrees per second.")]
    public float returnToCenterSpeed
    Field Value
    Type Description
    float

    steeringWheelGraphic

    The UI Graphic (typically an Image) representing the steering wheel that will rotate based on input. Must have a RectTransform component.

    Declaration
    public Graphic steeringWheelGraphic
    Field Value
    Type Description
    Graphic

    Methods

    DragEvent(BaseEventData)

    Called when the user drags their finger/mouse over the steering wheel. Calculates the rotation angle based on pointer position relative to the wheel center.

    Declaration
    public void DragEvent(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    Pointer event data containing touch/mouse position.

    GetClampedValue()

    Gets the current steering input value normalized to the range [-1, 1]. -1 = full left turn, 0 = center, 1 = full right turn. Compatible with standard input axis conventions (similar to Input.GetAxis("Horizontal")).

    Declaration
    public float GetClampedValue()
    Returns
    Type Description
    float

    Normalized steering value in range [-1, 1].

    PressEvent(BaseEventData)

    Called when the user touches/clicks the steering wheel. Initiates tracking of the pointer position for steering input.

    Declaration
    public void PressEvent(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    Pointer event data containing initial touch/mouse position.

    ReleaseEvent(BaseEventData)

    Called when the user releases the steering wheel. Triggers automatic return-to-center behavior.

    Declaration
    public void ReleaseEvent(BaseEventData eventData)
    Parameters
    Type Name Description
    BaseEventData eventData

    Pointer event data for the release event.

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