NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    Class SteeringWheel

    Draggable on-screen steering wheel for touch input. Returns steering in [-1, 1] and self-centers on release. 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

    Wheel travel in degrees to either side. Small values steer more sensitively.

    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

    Self-centering speed in degrees per second, applied while the wheel is not held.

    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)

    Drag handler. Turns the wheel by the pointer's angular travel about the wheel center.

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

    Pointer event data containing touch/mouse position.

    GetClampedValue()

    Steering normalized to [-1, 1]: -1 full left, 0 center, 1 full right.

    Declaration
    public float GetClampedValue()
    Returns
    Type Description
    float

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

    PressEvent(BaseEventData)

    Press handler. Claims the pointer and seeds the reference angle.

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

    Pointer event data containing initial touch/mouse position.

    ReleaseEvent(BaseEventData)

    Release handler. Frees the pointer and hands the wheel back to self-centering.

    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