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
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 towards 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. |
UpdateRecentering(float, bool, float)
Call this to manage re-centering axis value towards the supplied center value. This assumes that TrackValueChange() has been called already this frame.
Declaration
public void UpdateRecentering(float deltaTime, bool forceCancel, float center)
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. |
float | center | The value to recenter toward. |
Validate()
Make sure the settings are well-formed
Declaration
public void Validate()