Struct AxisState
Axis state for defining how to react to player input. The settings here control the responsiveness of the axis to player input.
Namespace: Cinemachine
Syntax
[DocumentationSorting(DocumentationSortingAttribute.Level.UserRef)]
[Serializable]
public struct AxisState
Constructors
AxisState(Single, Single, Boolean, Boolean, Single, Single, Single, String, Boolean)
Constructor with specific values
Declaration
public AxisState(float minValue, float maxValue, bool wrap, bool rangeLocked, float maxSpeed, float accelTime, float decelTime, string name, bool invert)
Parameters
Type | Name | Description |
---|---|---|
Single | minValue | |
Single | maxValue | |
Boolean | wrap | |
Boolean | rangeLocked | |
Single | maxSpeed | |
Single | accelTime | |
Single | decelTime | |
String | name | |
Boolean | invert |
Fields
m_AccelTime
The amount of time in seconds it takes to accelerate to MaxSpeed with the supplied Axis at its maximum value
Declaration
[Tooltip("The amount of time in seconds it takes to accelerate to MaxSpeed with the supplied Axis at its maximum value")]
public float m_AccelTime
Field Value
Type | Description |
---|---|
Single |
m_DecelTime
The amount of time in seconds it takes to decelerate the axis to zero if the supplied axis is in a neutral position
Declaration
[Tooltip("The amount of time in seconds it takes to decelerate the axis to zero if the supplied axis is in a neutral position")]
public float m_DecelTime
Field Value
Type | Description |
---|---|
Single |
m_InputAxisName
The name of this axis as specified in Unity Input manager. Setting to an empty string will disable the automatic updating of this axis
Declaration
[FormerlySerializedAs("m_AxisName")]
[Tooltip("The name of this axis as specified in Unity Input manager. Setting to an empty string will disable the automatic updating of this axis")]
public string m_InputAxisName
Field Value
Type | Description |
---|---|
String |
m_InputAxisValue
The value of the input axis. A value of 0 means no input You can drive this directly from a custom input system, or you can set the Axis Name and have the value driven by the internal Input Manager
Declaration
[Tooltip("The value of the input axis. A value of 0 means no input. You can drive this directly from a custom input system, or you can set the Axis Name and have the value driven by the internal Input Manager")]
public float m_InputAxisValue
Field Value
Type | Description |
---|---|
Single |
m_InvertInput
If checked, then the raw value of the input axis will be inverted before it is used.
Declaration
[FormerlySerializedAs("m_InvertAxis")]
[Tooltip("If checked, then the raw value of the input axis will be inverted before it is used")]
public bool m_InvertInput
Field Value
Type | Description |
---|---|
Boolean |
m_MaxSpeed
How fast the axis value can travel. Increasing this number makes the behaviour more responsive to joystick input
Declaration
[Tooltip("The maximum speed of this axis in units/second, or the input value multiplier, depending on the Speed Mode")]
public float m_MaxSpeed
Field Value
Type | Description |
---|---|
Single |
m_MaxValue
The maximum value for the axis
Declaration
[Tooltip("The maximum value for the axis")]
public float m_MaxValue
Field Value
Type | Description |
---|---|
Single |
m_MinValue
The minimum value for the axis
Declaration
[Tooltip("The minimum value for the axis")]
public float m_MinValue
Field Value
Type | Description |
---|---|
Single |
m_Recentering
Automatic recentering. Valid only if HasRecentering is true
Declaration
[Tooltip("Automatic recentering to at-rest position")]
public AxisState.Recentering m_Recentering
Field Value
Type | Description |
---|---|
AxisState.Recentering |
m_SpeedMode
How to interpret the Max Speed setting.
Declaration
[Tooltip("How to interpret the Max Speed setting: in units/second, or as a direct input value multiplier")]
public AxisState.SpeedMode m_SpeedMode
Field Value
Type | Description |
---|---|
AxisState.SpeedMode |
m_Wrap
If checked, then the axis will wrap around at the min/max values, forming a loop
Declaration
[Tooltip("If checked, then the axis will wrap around at the min/max values, forming a loop")]
public bool m_Wrap
Field Value
Type | Description |
---|---|
Boolean |
Value
The current value of the axis
Declaration
[Tooltip("The current value of the axis.")]
public float Value
Field Value
Type | Description |
---|---|
Single |
Properties
HasInputProvider
Returns true if this axis has an InputAxisProvider, in which case we ignore the input axis name
Declaration
public readonly bool HasInputProvider { get; }
Property Value
Type | Description |
---|---|
Boolean |
HasRecentering
True if the Recentering member is valid (bcak-compatibility support: old versions had recentering in a separate structure)
Declaration
public bool HasRecentering { readonly get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ValueRangeLocked
Value range is locked, i.e. not adjustable by the user (used by editor)
Declaration
public bool ValueRangeLocked { readonly get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Reset()
Cancel current input state and reset input to 0
Declaration
public void Reset()
SetInputAxisProvider(Int32, AxisState.IInputAxisProvider)
Set an input provider for this axis. If an input provider is set, the provider will be queried when user input is needed, and the Input Axis Name field will be ignored. If no provider is set, then the legacy Input system will be queried, using the Input Axis Name.
Declaration
public void SetInputAxisProvider(int axis, AxisState.IInputAxisProvider provider)
Parameters
Type | Name | Description |
---|---|---|
Int32 | axis | Which axis will be queried for input |
AxisState.IInputAxisProvider | provider | The input provider |
Update(Single)
Updates the state of this axis based on the Input axis defined by AxisState.m_AxisName
Declaration
public bool Update(float deltaTime)
Parameters
Type | Name | Description |
---|---|---|
Single | deltaTime | Delta time in seconds |
Returns
Type | Description |
---|---|
Boolean | Returns true if this axis's input was non-zero this Update, false otherwise |
Validate()
Call from OnValidate: Make sure the fields are sensible
Declaration
public void Validate()