Composite bindings
Combine several controls into one value with composite bindings, and choose from the composite types the Input System provides.
A composite binding is a binding made up of other bindings. Use composite bindings to combine several controls so they act in unison and mimic a different type of control. For example, the W, A, S, and D keys on the keyboard can form a 2D vector control equivalent to mouse deltas or gamepad sticks, and two keys can form a 1D axis equivalent to a mouse scroll axis.
A composite doesn't bind directly to controls. Instead, it reads values from its parts, which do bind to controls, and synthesizes a new value from them at runtime.
Simple bindings can't combine controls in this way. For example, you can bind a ButtonControl to an action that expects a Vector2, but this causes an exception at runtime when the Input System tries to read a Vector2 from a control that delivers only a float.
To add a composite binding to an action, refer to Add, duplicate, or delete a binding. To assign controls to the composite's parts, refer to Edit composite bindings.
Types of composite bindings
Each composite type has a different name in each place you use it: the menu you add bindings with, the Composite Type property in the Binding Properties panel, and the name you use in code. The Input System provides the following composite types.
| Add menu entry | Composite Type | Name in code | Output |
|---|---|---|---|
| Add Positive/Negative Binding | 1D Axis | 1DAxis or Axis |
float |
| Add Up/Down/Left/Right Composite | 2D Vector | 2DVector or Dpad |
Vector2 |
| Add Up/Down/Left/Right/Forward/Backward Composite | 3D Vector | 3DVector |
Vector3 |
| Add Binding With One Modifier | One Modifier | OneModifier |
The value type of the control bound to the Binding part |
| Add Binding With Two Modifiers | Two Modifiers | TwoModifiers |
The value type of the control bound to the Binding part |
When you add a binding to an action, the menu lists only the composite types whose output type matches the action's Control Type. If the Control Type is Any, the menu lists all composite types. Composite types without a fixed output type, such as the one modifier and two modifier composites, appear for every Control Type.
For the parts and parameters of each composite type, refer to Composite types reference.
Custom composites
The menu can also list custom composites in your project. If you register a composite with InputSystem.RegisterBindingComposite from code that runs in edit mode, the menu always lists it. The Input System can also find unregistered composite classes, such as composites in imported samples or test assemblies, but only the first time it fails to look up a type by name. Until then, those composites might not appear in the menu. For more information, refer to Create custom composite bindings.