Skip to content

Latest commit

 

History

History
109 lines (77 loc) · 9.59 KB

File metadata and controls

109 lines (77 loc) · 9.59 KB
uid input-system-built-in-interactions

Built-in interactions

The Input System package comes with a set of built-in interactions, which you can use on actions and bindings:

  • PressInteraction
  • HoldInteraction
  • TapInteraction
  • SlowTapInteraction
  • MultiTapInteraction

Each built-in Interaction has its own parameters, and responds differently to Interaction callbacks.

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.

Parameters Type Default value
pressPoint float InputSettings.defaultButtonPressPoint
behavior PressBehavior 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 pressPoint
or
- 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.

Parameters Type Default value
duration float InputSettings.defaultHoldTime
pressPoint float InputSettings.defaultButtonPressPoint

To display UI feedback when a button starts being held, use the started callback.

    action.started += _ => ShowGunChargeUI();
    action.performed += _ => FinishGunChargingAndHideChargeUI();
    action.cancelled += _ => 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.

Parameters Type Default value
duration float InputSettings.defaultTapTime
pressPoint float InputSettings.defaultButtonPressPoint
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.

Parameters Type Default value
duration float InputSettings.defaultSlowTapTime
pressPoint float InputSettings.defaultButtonPressPoint
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.

Parameters Type Default value
tapTime float InputSettings.defaultTapTime
tapDelay float 2 * tapTime
tapCount int 2
pressPoint float InputSettings.defaultButtonPressPoint
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).