Built-in interactions
The Input System package comes with a set of built-in interactions, which you can use on actions and bindings:
Each built-in Interaction has its own parameters, and responds differently to Interaction callbacks.
Many parameters default to a value in the Input settings. In the Inspector, a parameter that uses its default value has Default enabled. To set your own value for a binding or action, disable Default and enter the value. To change the default for all bindings and actions, change the setting in Edit > Project Settings > Input System Package. For more information, refer to Default value properties.
Note
The built-in Interactions operate on Control actuation and don't use Control values directly. The Input System evaluates the pressPoint parameters against the magnitude of the Control actuation. This means you can use these Interactions on any Control which has a magnitude, such as sticks, and not just on buttons.
If an action or binding has no interaction set, the system uses its default Interaction.
Press
You can use a PressInteraction to explicitly force button-like interactions. Use the behavior parameter to select if the Interaction should trigger on button press, release, or both.
| Parameter | Inspector label | Type | Description | Default value |
|---|---|---|---|---|
pressPoint |
Press Point | float |
The amount of actuation a control requires before the Input System considers it pressed. | The Default Button Press Point setting |
behavior |
Trigger Behavior | PressBehavior |
Whether the interaction triggers on press, on release, or on both. | PressOnly |
Callbacks/behavior |
PressOnly |
ReleaseOnly |
PressAndRelease |
|---|---|---|---|
started |
Control magnitude crosses pressPoint |
Control magnitude crosses pressPoint |
Control magnitude crosses pressPoint |
performed |
Control magnitude crosses pressPoint |
Control magnitude goes back below pressPoint |
- Control magnitude crosses pressPointor - Control magnitude goes back below pressPoint |
canceled |
not used | not used | not used |
Hold
A HoldInteraction requires the user to hold a Control for duration seconds before the Input System triggers the Action.
| Parameter | Inspector label | Type | Description | Default value |
|---|---|---|---|---|
duration |
Hold Time | float |
The time, in seconds, that the user must hold the control for the interaction to register a hold. | The Default Hold Time setting |
pressPoint |
Press Point | float |
The amount of actuation a control requires before the Input System considers it pressed. | The Default Button Press Point setting |
To display UI feedback when a button starts being held, use the started callback.
action.started += _ => ShowGunChargeUI();
action.performed += _ => FinishGunChargingAndHideChargeUI();
action.canceled += _ => HideChargeUI();
| Callbacks | |
|---|---|
started |
Control magnitude crosses pressPoint. |
performed |
Control magnitude held above pressPoint for >= duration. |
canceled |
Control magnitude goes back below pressPoint before duration (that is, the button was not held long enough). |
Tap
A TapInteraction requires the user to press and release a Control within duration seconds to trigger the Action.
| Parameter | Inspector label | Type | Description | Default value |
|---|---|---|---|---|
duration |
Max Tap Duration | float |
The maximum time, in seconds, between when the user presses and releases the control for the interaction to register a tap. If the user holds the control longer, the tap is canceled. | The Default Tap Time setting |
pressPoint |
Press Point | float |
The amount of actuation a control requires before the Input System considers it pressed. | The Default Button Press Point setting |
| Callbacks | |
|---|---|
started |
Control magnitude crosses pressPoint. |
performed |
Control magnitude goes back below pressPoint before duration. |
canceled |
Control magnitude held above pressPoint for >= duration (that is, the tap was too slow). |
SlowTap
A SlowTapInteraction requires the user to press and hold a Control for a minimum duration of duration seconds, and then release it, to trigger the Action.
| Parameter | Inspector label | Type | Description | Default value |
|---|---|---|---|---|
duration |
Min Tap Duration | float |
The minimum time, in seconds, that the user must hold the control for the interaction to register a slow tap. If the user releases the control sooner, the slow tap is canceled. | The Default Slow Tap Time setting |
pressPoint |
Press Point | float |
The amount of actuation a control requires before the Input System considers it pressed. | The Default Button Press Point setting |
| Callbacks | |
|---|---|
started |
Control magnitude crosses pressPoint. |
performed |
Control magnitude goes back below pressPoint after duration. |
canceled |
Control magnitude goes back below pressPoint before duration (that is, the tap was too fast). |
MultiTap
You can use MultiTap to detect double-click or multi-click gestures. For a MultiTapInteraction to trigger, the user must press a control and release it within tapTime seconds, repeating the press-and-release process tapCount times. There can't be more than tapDelay seconds between taps.
| Parameter | Inspector label | Type | Description | Default value |
|---|---|---|---|---|
tapTime |
Max Tap Duration | float |
The maximum time, in seconds, that the user can hold the control for each tap. If the user holds the control longer, the multi-tap is canceled. | The Default Tap Time setting |
tapDelay |
Max Tap Spacing | float |
The maximum time, in seconds, between taps. If the next tap takes longer, the multi-tap is canceled. | The MultiTap Delay Time setting |
tapCount |
Tap Count | int |
The number of taps the user must make in a row. For example, 2 is a double tap. |
2 |
pressPoint |
Press Point | float |
The amount of actuation a control requires before the Input System considers it pressed. | The Default Button Press Point setting |
| Callbacks | |
|---|---|
started |
Control magnitude crosses pressPoint. |
performed |
Control magnitude went back below pressPoint and back up above it repeatedly for tapCount times. |
canceled |
- After going back below pressPoint, Control magnitude did not go back above pressPoint within tapDelay time (that is, taps were spaced out too far apart).or - After going back above pressPoint, Control magnitude did not go back below pressPoint within tapTime time (that is, taps were too long). |