GestureCombo Icon

Gesture Combo

1. Introduction

Welcome to the GestureComboTouch solution. This asset provides a powerful and modular approach to implementing both simple and advanced touch and gesture controls in Unity. Easily integrate taps, swipes, holds, and multi-touch gestures like pinch and rotate to enhance your game's interactivity.

2. Installation and Basic Requirements

  1. Activate Unity Input System
  2. EventSystem
    • Ensure an EventSystem is present in your scene (Hierarchy). If missing, add one via Create → UI → Event System.
  3. Import Asset
    • Import all scripts from the New Input System Pro – Gesture Combo & Joystick Touch assets using the Package Manager in My Assets.

3. GestureComboManager: Define Gesture Sequences

Use the GestureComboManager to create complex gesture sequences (combos). A combo consists of multiple steps (e.g., "Tap" → "SwipeLeft" → "Tap"). When the sequence is performed correctly, the associated action is triggered.

Use the prefabs out of the Prefab folder or build your own.

3.1. Create Manager Object

Create an empty GameObject in your scene (e.g., "GestureComboManager") and add the GestureComboManager script to the GameObject.

3.2. Combo Manager Settings

Screenshot: Combo Manager Settings

Setting Description
Debug Enabled Enables runtime debug logging for gesture detection and combo execution.
Allow Combo Abort Allows incomplete or incorrect gestures to cancel the current combo.
Abort Executes Last Step Executes the last valid combo step before aborting the combo (if enabled).
Use API Activates API reporting for executed steps.
Identifier A unique string used to reference this manager when using the API.
Add New Combo Adds a new gesture combo definition with custom steps and actions.

3.3 Create Combos and Define Steps

Each gesture combo consists of a sequence of steps. Every step defines what gesture is expected, how it's triggered, and how it connects to Unity's input and event system.

Screenshot: Combo Step Details
Field Description
Name Combo Name of the entire gesture combo. Used in debugging and API reporting.
Step Name The name of the step; used for logs and API calls.
Gesture Gesture that must be performed to complete this step (e.g. Tap, Swipe, Hold).
Duration Max allowed time (in seconds) before the next gesture must occur.
Always Active If true, this step is executed immediately without waiting for the full combo.
Using Input System Whether to use Unity's Input System binding via Control Path.
Action Mode Defines how the step is triggered (Trigger: triggered one time, Toggel: turns it on and next time off, ToggelON/OFF: turns it only ON or OFF) .
Control Path Input System control path (ActionMap) (e.g. "<Touchscreen>/primaryTouch/press").
Using Unity Events Enables Unity Events for this step so that actions can be triggered without code.

Special Handling for Hold Gestures

Hold gestures support more detailed configuration with dedicated fields to fine-tune the interaction timing and response.

Screenshot: Combo Step Details
Hold Field Description
Hold Time Required duration (in seconds) the user must hold before this step is triggered.
Hold Start Triggers the step at the beginning of the hold (instead of after Hold Time).
Hold End Triggers the step when the user releases after a successful hold.
Hold Start Control Path Optional input binding used specifically to detect the hold start event (e.g. virtual button).

4. Simple Gesture Recognition via TouchGestureInput

Use the TouchGestureInput script for detecting one-finger gestures such as Tap, Hold, or Swipe. Create a new GameObject (e.g. SingleTouchController), attach the script, and assign a RectTransform to define the active touch area. If needed, use the Rect Visualizer Editor skript an put it into the same GameObject where you have TouchGestureInput skript to preview the area in the editor.

Screenshot: Combo Step Details
Field Description
Touch Identifier Unique reference used to filter touch events and API calls.
Gesture Managers List of GestureComboManager instances to forward recognized gestures to.
Tap Max Time Maximum time (in seconds) for a touch to be considered a tap.
Hold Time Minimum duration to trigger a hold gesture.
Swipe Threshold Minimum distance (in pixels) the finger must move to register a swipe.
Max Tap Movement Maximum movement allowed during a tap. Prevents false positives on small swipes.
Touch Area RectTransform to limit input to a specific screen area.
Ignore UI Element If enabled, touches over UI elements will still be processed.
Use API Sends gesture data to external systems via the API (e.g. for analytics or syncing).
Debug Enabled Logs recognized gestures to the console for debugging purposes.

Gesture Types Detected

  • Tap: Quick touch with minimal movement.
  • Hold: Finger held down for Hold Time without moving.
  • Swipe: Directional gesture once movement exceeds the Swipe Threshold (supports Up, Down, Left, Right).

Hold Gesture Flow

When a hold gesture is detected, the following sequence is triggered:

  1. Hold Start: Triggered when hold duration is reached.
  2. Hold End: Triggered when the finger is released after a hold.

You can react to both phases in your combo logic or via API callbacks.

Switching Gesture Managers at Runtime

To switch the active GestureComboManager during runtime, you can call:

        touchInput.SwitchGestureManager(targetIndex);
        

This method can also be called via Unity Events. Simply add a UnityEvent in the Inspector and assign the SwitchGestureManager(int index) function with the desired index as parameter.

Screenshot: Combo Step Details

Alternatively, you can trigger the event-based API

5. Multi-Touch Gesture Input for Pinch and Rotation

The MultiTouchGestureInput script detects two-finger gestures such as Rotation and Pinch (Zoom). Add it to a GameObject (e.g. MultiTouchController) and define the active area via RectTransform. If needed, use the Rect Visualizer Editor skript an put it into the same GameObject where you have the MultiTouchGestureInput skript to preview the area in the editor.

You can either send gesture data to an external API or trigger combo steps in the GestureComboManager.

Screenshot: Combo Step Details
Field Description
Multitouch Identifier Unique reference used to filter touch events and API calls.
Gesture Managers List of GestureComboManager targets for gesture execution.
Touch Area RectTransform to limit input to a specific screen area.
Ignore UI Element If true, gestures over UI elements are still recognized.
Output Rotation to API If true, rotation data is sent to API instead of triggering a combo.
Output Pinch to API If true, pinch/zoom data is sent to API instead of triggering a combo.
Zoom Speed Multiplier for pinch sensitivity.
Rotation Speed Multiplier for rotation sensitivity.
Rotation Bias Factor Higher values favor rotation over pinch when both are detected.
Base Rotation Threshold Minimum angular change (degrees) to begin detecting rotation.
Rotation Activation Threshold Minimum delta to trigger rotation step (filters noise).
Pinch Threshold Minimum distance change (pixels) to begin detecting pinch.
Pinch Activation Threshold Minimum delta to trigger pinch step (filters noise).
Debug Enabled Logs gesture recognition events to the console.

Detected Gestures

  • Rotation Left / Right: Triggered by two-finger rotation above threshold.
  • Pinch In / Out: Triggered by two-finger pinch zooming in or out.

Switching Gesture Managers at Runtime

To switch the active GestureComboManager during runtime, you can call:

        multiTouchInput.SwitchGestureManager(targetIndex);
        

This method can also be called via Unity Events. Simply add a UnityEvent in the Inspector and assign the SwitchGestureManager(int index) function with the desired index as parameter.

Screenshot: Combo Step Details

Alternatively, you can trigger the event-based API