如何检测Leap motion中的手是否朝上(C#)Unity

时间:2017-02-05 12:17:54

标签: c# unity3d unity5 leap-motion

我正在制作一个游戏,当我面向掌心时,保存和加载系统将显示出来。问题是,我不知道如何检测我的手掌是否朝上。我所知道的是如何获得手掌距离和位置。

我试过了:

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);
}
}

但它返回错误:

  

无法将索引应用于表达式类型

1 个答案:

答案 0 :(得分:1)

尝试*

Hand hand = frame.Hands[0];

要确定手掌是否朝上,请将Hand.PalmNormal与向上的向量进行比较 - 但是您要定义“向上”。

由于您使用较新的Orion资产进行Leap Motion,您还可以使用PalmDirectionDetector脚本。

*这是一个糟糕的设计选择,有一个名为Hand()的函数和一个名为Hands的数组。

相关问题