1

I'm making a game where the save and load system is going to show when I face my palm up. The problem is, I don't know how I can detect if my palm is facing up. All I know is how to get the palm distance and position.

I tried this:

using Leap;
using Leap.Unity;

public class GetPamlPositionLeap : MonoBehaviour {
LeapProvider provider;
// Use this for initialization
void Start () {
    provider = FindObjectOfType<LeapProvider>() as LeapProvider;
}

// Update is called once per frame
void Update () {
    Frame frame = provider.CurrentFrame;
    Hand hand = frame.Hand [0]; // cannot apply indexing
    Vector position = hand.PalmPosition;
    Vector direction = hand.Direction;

    Debug.Log ("The position of hand is" + position + "The direction of hand is" + direction);
}
}

But it returns error:

cannot apply indexing to an expression type

Gordon Bell
  • 13,337
  • 3
  • 45
  • 64
Ginxxx
  • 1,602
  • 2
  • 25
  • 54

1 Answers1

1

Try*

Hand hand = frame.Hands[0];

To decide whether the palm is facing up, compare the Hand.PalmNormal with a vector that is pointing up -- however you define "up."

Since you are using the newer Orion assets for Leap Motion, you could also use the PalmDirectionDetector script.

*It was a poor design choice of have a function named Hand() and an array named Hands.

Charles Ward
  • 1,388
  • 1
  • 8
  • 13
  • See the palmWatcher function here: https://github.com/leapmotion/UnityModules/blob/develop/Assets/LeapMotion/Scripts/DetectionUtilities/PalmDirectionDetector.cs – Charles Ward Feb 06 '17 at 18:17