Gestures Gem - Lumberyard User Guide

Gestures Gem

Open 3D Engine (O3DE), the successor to Lumberyard, is now available in Developer Preview. Download O3DE or visit the AWS Game Tech blog to learn more.

You can use the Gestures gem to recognize common gesture-based input, which includes the following:

  • Tap or click – Single-touch, discrete gesture

  • Drag or pan – Single-touch, continuous gesture

  • Hold or press – Single-touch, continuous gesture

  • Swipe – Single-touch, discrete gesture

  • Pinch – Multiple-touch, continuous gesture

  • Rotate – Multiple-touch, continuous gesture

Single-touch gestures (such as tap, drag, hold, and swipe) can be detected with touch or mouse input. However, multiple-touch gestures (such as pinch and rotate) can only be recognized on multi-touch enabled devices such as iOS or Android. You can extend the underlying C++ gesture recognition framework to support your custom gesture recognizers.

            Enable the Gestures gem to detect common gesture input actions.

To enable the Gestures gem for your project, see Add modular features and assets with Gems.

Configuring Gesture Recognizers

You can configure gesture recognizers with C++ and the Gestures system component in the System Entity Editor. For more information, see Configuring Advanced Settings.

To configure gesture recognizers

  1. In the Project Configurator, click Advanced Settings.

  2. In the System Entity Editor, click Add Component, and then expand Gestures.

  3. For each gesture recognizer, specify your preferred values. For example, if you want to change the Min Clicks or Taps for a double press gesture, specify a new value.

                        Use the System Entity Editor to manage the gesture settings.

    Pause on the gesture recognizer to see a description and the valid values.

  4. Make your changes and then click Save.

Responding to Gesture Input

Each gesture recognizer that the Gestures system component exposes corresponds to a gesture input channel that belongs to a gesture input device.

You can use gesture input channels in the same way as other input channels with C++, Lua, or Script Canvas. You can map the gesture input channels to gameplay actions with an Input component. This component is part of the Input Management Framework and Starting Point Input gems.

To add input to an entity, see the Input component.

Example Lua Script

The following script listens for and responds to the default double press gesture.

function GestureExample:OnActivate() self.inputChannelNotificationBus = InputChannelNotificationBus.Connect(self); end function GestureExample:OnInputChannelEvent(inputChannel) if (inputChannel.channelName == InputDeviceGestures.gesture_double_press) then -- Respond to the default double press gesture end end function GestureExample:OnDeactivate() if (self.inputChannelNotificationBus) then self.inputChannelNotificationBus:Disconnect(); end end

For more information, see Input in Amazon Lumberyard.