NWH Common
Search Results for

    Show / Hide Table of Contents

    Class InputUtils

    Utility methods for safe input retrieval with automatic fallback to default keys. Prevents errors when Input Manager bindings are missing.

    Inheritance
    object
    InputUtils
    Namespace: NWH.Common.Input
    Assembly: NWH.Common.dll
    Syntax
    public class InputUtils

    Methods

    | Edit this page View Source

    TryGetAxis(string, bool)

    Attempts to retrieve axis value from Input Manager, returns 0 if binding is missing.

    Declaration
    public static float TryGetAxis(string axisName, bool showWarning = true)
    Parameters
    Type Name Description
    string axisName

    Input Manager axis name to query.

    bool showWarning

    Display warning message when axis is missing.

    Returns
    Type Description
    float

    Axis value between -1 and 1, or 0 if binding is missing.

    | Edit this page View Source

    TryGetAxisRaw(string, bool)

    Attempts to retrieve raw axis value from Input Manager, returns 0 if binding is missing. Raw axes return only -1, 0, or 1 without smoothing.

    Declaration
    public static float TryGetAxisRaw(string axisName, bool showWarning = true)
    Parameters
    Type Name Description
    string axisName

    Input Manager axis name to query.

    bool showWarning

    Display warning message when axis is missing.

    Returns
    Type Description
    float

    Raw axis value (-1, 0, or 1), or 0 if binding is missing.

    | Edit this page View Source

    TryGetButton(string, KeyCode, bool)

    Attempts to retrieve button state from Input Manager, falls back to KeyCode if binding is missing.

    Declaration
    public static bool TryGetButton(string buttonName, KeyCode altKey, bool showWarning = true)
    Parameters
    Type Name Description
    string buttonName

    Input Manager button name to query.

    KeyCode altKey

    Fallback KeyCode to use if binding is missing.

    bool showWarning

    Display warning message when falling back to default key.

    Returns
    Type Description
    bool

    True if button is currently held down.

    | Edit this page View Source

    TryGetButtonDown(string, KeyCode, bool)

    Attempts to retrieve button press from Input Manager, falls back to KeyCode if binding is missing.

    Declaration
    public static bool TryGetButtonDown(string buttonName, KeyCode altKey, bool showWarning = true)
    Parameters
    Type Name Description
    string buttonName

    Input Manager button name to query.

    KeyCode altKey

    Fallback KeyCode to use if binding is missing.

    bool showWarning

    Display warning message when falling back to default key.

    Returns
    Type Description
    bool

    True on the frame the button was pressed.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics