Class AxisComposite
A single [-1..1] axis value computed from a "negative" and a "positive" button.
Inherited Members
Namespace: UnityEngine.Experimental.Input.Composites
Syntax
public class AxisComposite : InputBindingComposite<float>, IInputBindingComposite<float>, IInputBindingComposite
Remarks
This composite allows to arrange any arbitrary two buttons from a device in an axis configuration such that one button pushes in one direction and the other pushes in the opposite direction.
If both buttons are pressed at the same time, the behavior depends on whichSideWins. By default, neither side will win (Neither) and the result will be 0. This can be customized to make the positive side win (Positive) or the negative one (Negative).
This is useful, for example, in a driving game where break should cancel out accelerate. By binding negative to the break control(s) and positive to the acceleration control(s), and setting whichSideWins to Negative, if the break button is pressed, it will always cause the acceleration button to be ignored.
The values returned are the actual actuation values of the buttons, unaltered for positive and inverted for negative. This means that if the buttons are actual axes (e.g. the triggers on gamepads), then the values correspond to how much the axis is actuated.
Fields
negative
Binding for the button that controls the positive direction of the axis.
Declaration
public int negative
Field Value
Type | Description |
---|---|
System.Int32 |
positive
Binding for the button that controls the negative direction of the axis.
Declaration
public int positive
Field Value
Type | Description |
---|---|
System.Int32 |
whichSideWins
If both the positive and negative button are actuated, this determines which value is returned from the composite.
Declaration
public AxisComposite.WhichSideWins whichSideWins
Field Value
Type | Description |
---|---|
AxisComposite.WhichSideWins |
Methods
ReadValue(ref InputBindingCompositeContext)
Declaration
public override float ReadValue(ref InputBindingCompositeContext context)
Parameters
Type | Name | Description |
---|---|---|
InputBindingCompositeContext | context |
Returns
Type | Description |
---|---|
System.Single |