By Shira Wu

1.1 Leap Motion

image from https://images.app.goo.gl/L3Tn7btihfcvA7UM6

image from https://images.app.goo.gl/L3Tn7btihfcvA7UM6

1.1.1 Device Evaluation

1.1.2 Actual Requirements

In addition to basic gestures like a fist and an open palm, there are additional gesture recognition requirements. The principle of gesture recognition in "Daydream Fantasy" is stability and avoiding gesture conflicts, with gestures being as few as possible while maximizing their significance.

1.1.3 Core Functions

The core requirement of "Daydream Fantasy" is single-hand gesture recognition, which includes recognizing open palm, fist, and OK gestures. By using Leap Motion's pre-packaged headers, Unity developers can easily define hand models and customize gestures by distinguishing fingers.

using Leap;
using Leap.Unity

public HandModelBase leftHandModel;

Finger.FingerType[] arr12 = { Finger.FingerType.TYPE_THUMB, Finger.FingerType.TYPE_INDEX };

// Custom finger definitions
/*
TYPE_THUMB = 0 for thumb
TYPE_INDEX = 1 for index finger
TYPE_MIDDLE = 2 for middle finger
TYPE_RING = 3 for ring finger
TYPE_PINKY = 4 for pinky finger
*/
// Hand Recognition
bool IsOpenFullHand(Hand hand)
{
    return hand.GrabStrength == 0;
}
// Fist recognition by measuring the distance from fingertips to palm center
bool IsCloseHand(Hand hand)
{
    List<Finger> listOfFingers = hand.Fingers;
    int count = 0;
    for (int f = 0; f < listOfFingers.Count; f++)
    {
        Finger finger = listOfFingers[f];
        if ((finger.TipPosition - hand.PalmPosition).Magnitude < 2f)
        {
            count++;
        }
    }
    return (count == 5);
}
// OK gesture recognition by measuring the distance between different fingertips
if ((listOfFingers[0].TipPosition - listOfFingers[1].TipPosition).Magnitude < deltaCloseFinger)
{
    // Recognize OK gesture
}

1.2 Game Framework

During the game, gesture control is always on, but Leap Motion can only recognize and validate gestures when the gesture window (which functions as equipment) is open. This allows players to interact with the scene using these gestures. To implement the "equipment" feature of gestures, the game framework is primarily built around the DontDestroyOnLoad function. This function ensures that objects are not destroyed during scene transitions and remain in their pre-transition state.