Search code examples
unity-game-engineswipegestureleap-motion

Leap motion Hand swipe


I am currently developing an application in Unity that uses the leap motion swipe gesture. Swiping with the hand in a vertical position is not reliable. Can someone please help with a swipe Gesture that uses the Hand instead of the fingers. Thanks


Solution

  • I find that with a vertical hand, you get a swipe from at least one finger near the start of the user's gesture. Given this, the easiest way to work around the problem with vertical hands is probably to trigger your swipe behavior using the built in swipe gesture, but then to track the hand "manually" until you decide that the swipe is over. As an example, your logic could be something like this:

    Your app has a NOT_SWIPING and a SWIPING state.

    In the NOT_SWIPING state, you would examine the built-in gesture objects in each frame. If there is a swipe gesture object that meets your criteria (e.g. maybe you require it to be basically horizontal), you set the app to the SWIPING state, store the Hand object and start whatever reaction in your app that is affected by swiping.

    In the SWIPING state, you check whether the hand is still swiping by examining its change in position since the last frame. If you decide the hand is still swiping (e.g. its motion is still in a relatively straight line), you update the app appropriately. Otherwise, you set the app state to NOT_SWIPING and cancel or complete the app-defined swipe behavior.

    This scheme could be extended to support simultaneous swipes by different hands by letting new swipes start if the hand isn't already swiping. You would probably want to make your own Swipe class and keep a list of Swipe instances to keep track of this.