docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct InputAxis

    Defines an input axis. This is a field that can take on any value in a range, with optional wrapping to form a loop.

    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Unity.Cinemachine
    Assembly: Unity.Cinemachine.dll
    Syntax
    [Serializable]
    public struct InputAxis

    Fields

    Center

    The centered, or at-rest value of this axis.

    Declaration
    [Delayed]
    [Tooltip("The centered, or at-rest value of this axis.")]
    public float Center
    Field Value
    Type Description
    float

    Range

    The valid range for the axis value. Value will be clamped to this range.

    Declaration
    [Tooltip("The valid range for the axis value.  Value will be clamped to this range.")]
    public Vector2 Range
    Field Value
    Type Description
    Vector2

    Recentering

    Controls automatic re-centering of axis

    Declaration
    [FoldoutWithEnabledButton("Enabled")]
    public InputAxis.RecenteringSettings Recentering
    Field Value
    Type Description
    InputAxis.RecenteringSettings

    Restrictions

    Some usages require restricted functionality. This is set here.

    Declaration
    [HideInInspector]
    public InputAxis.RestrictionFlags Restrictions
    Field Value
    Type Description
    InputAxis.RestrictionFlags

    Value

    The current value of the axis. You can drive this directly from a script

    Declaration
    [Tooltip("The current value of the axis.  You can drive this directly from a script.")]
    public float Value
    Field Value
    Type Description
    float

    Wrap

    If set, then the axis will wrap around at the min/max values, forming a loop

    Declaration
    [Tooltip("If set, then the axis will wrap around at the min/max values, forming a loop")]
    public bool Wrap
    Field Value
    Type Description
    bool

    Properties

    DefaultMomentary

    An InputAxis set up as a normalized momentary control ranging from -1...1 with Center = 0

    Declaration
    public static InputAxis DefaultMomentary { get; }
    Property Value
    Type Description
    InputAxis

    Methods

    CancelRecentering()

    Cancel any current re-centering in progress, and reset the wait time

    Declaration
    public void CancelRecentering()

    ClampValue(float)

    Clamp the value to range, taking wrap into account

    Declaration
    public float ClampValue(float v)
    Parameters
    Type Name Description
    float v

    The value to clamp

    Returns
    Type Description
    float

    The value clamped to the axis range

    GetClampedValue()

    Get the clamped axis value

    Declaration
    public float GetClampedValue()
    Returns
    Type Description
    float

    The axis value, clamped to the axis range

    GetNormalizedValue()

    Clamp and scale the value to range 0...1, taking wrap into account

    Declaration
    public float GetNormalizedValue()
    Returns
    Type Description
    float

    The axis value, mapped onto [0...1]

    Reset()

    Reset axis to at-rest state

    Declaration
    public void Reset()

    TrackValueChange()

    Call this before calling UpdateRecentering. Will track any value changes so that the re-centering clock is updated properly.

    Declaration
    public bool TrackValueChange()
    Returns
    Type Description
    bool

    True if value changed. This value can be used to cancel re-centering when multiple input axes are coupled.

    TriggerRecentering()

    Trigger re-centering immediately, regardless of whether re-centering is enabled or the wait time has elapsed.

    Declaration
    public void TriggerRecentering()

    UpdateRecentering(float, bool)

    Call this to manage re-centering axis value to axis center. This assumes that TrackValueChange() has been called already this frame.

    Declaration
    public void UpdateRecentering(float deltaTime, bool forceCancel)
    Parameters
    Type Name Description
    float deltaTime

    Current deltaTime, or -1 for immediate re-centering

    bool forceCancel

    If true, cancel any re-centering currently in progress and reset the timer.

    Validate()

    Make sure the settings are well-formed

    Declaration
    public void Validate()
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)