2017-02-05 7 views
1

私は手のひらを上にしたときにセーブおよびロードシステムが表示されるゲームを作っています。問題は、私の手のひらが上を向いているかどうかをどのように検出できるかわかりません。私が知っているのは、手のひらの距離と位置を得る方法です。跳躍動作の手が上を向いているかどうかを検出する方法(C#)Unity

私はこの試みた:

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

をしかし、それはエラーを返します:

cannot apply indexing to an expression type

答えて

1

はHand.PalmNormalを比較し、手のひらを上に向けているかどうかを決定するには*

Hand hand = frame.Hands[0]; 

をお試しください上に向いているベクトルで - しかし、あなたは "上"を定義します。

Leap Motionに新しいOrionアセットを使用しているため、PalmDirectionDetectorスクリプトを使用することもできます。

*これは、Hand()という名前の関数とHandsという名前の配列を持つ設計が不適切です。

+0

あなたはこの先生のサンプルを私に見せてもらえますか? please – TheGinxx009

+0

palmWatcher関数を参照してください:https://github.com/leapmotion/UnityModules/blob/develop/Assets/LeapMotion/Scripts/DetectionUtilities/PalmDirectionDetector.cs –

関連する問題