2017-06-21 6 views
0

私は、Unityプロジェクトでの跳躍動作のHTC Viveのコントローラーに似た機能を実装しようとしています。私は人差し指からレーザーポインターを生成し、レーザーの位置にViveの部屋をテレポートしたいと思っていました。問題は、最新の飛躍動作(orion)のドキュメントです。それは不明です。任意のアイデアをどのように行うには?一般的には、HandControllerの使用について考えましたが、スクリプトコンポーネントをどこに追加するかはわかりません。 ありがとう!Htc Vive +コントローラーとしての躍動

答えて

0

問題が発生しているかどうかは、シーン内に手データをまったく取得しているのか、その手データを使用しているのかは不明です。

シーン内の手のデータを取得しようとしている場合は、Unity SDKのサンプルシーンの1つからプレハブをコピーできます。すでにVRリグが設定されている既存のシーンにLeapを統合しようとしている場合は、the core Leap componentsのドキュメントを参照して、Handデータの取得を開始するために必要な部分を理解してください。 LeapServiceProviderは、ハンドデータを受け取るためにシーンのどこかにある必要があります。

限り、あなたはどこかにLeapServiceProviderを持っているとして、あなたはどこでもからリープモーションから任意のスクリプトを手にアクセスすることができます。だから、ただの古い場所にこのスクリプトをポップ、インデックス指先から光線を得るために:それは価値がある何のため

using Leap; 
using Leap.Unity; 
using UnityEngine; 

public class IndexRay : MonoBehaviour { 
    void Update() { 
    Hand rightHand = Hands.Right; 
    Vector3 indexTipPosition = rightHand.Fingers[1].TipPosition.ToVector3(); 
    Vector3 indexTipDirection = rightHand.Fingers[1].bones[3].Direction.ToVector3(); 
    // You can try using other bones in the index finger for direction as well; 
    // bones[3] is the last bone; bones[1] is the bone extending from the knuckle; 
    // bones[0] is the index metacarpal bone. 

    Debug.DrawRay(indexTipPosition, indexTipDirection, Color.cyan); 
    } 
} 

、インデックス指先の方向は、おそらくあなたが欲しいものを行うのに十分安定であることを行っていません。より信頼性の高い戦略は、カメラのライン(または、カメラからの一定のオフセットで理論的な「肩の位置」)を手のインデックスナックルボーンを介してキャストすることです:

using Leap; 
using Leap.Unity; 
using UnityEngine; 

public class ProjectiveRay : MonoBehaviour { 

    // To find an approximate shoulder, let's try 12 cm right, 15 cm down, and 4 cm back relative to the camera. 
    [Tooltip("An approximation for the shoulder position relative to the VR camera in the camera's (non-scaled) local space.")] 
    public Vector3 cameraShoulderOffset = new Vector3(0.12F, -0.15F, -0.04F); 

    public Transform shoulderTransform; 

    void Update() { 
    Hand rightHand = Hands.Right; 
    Vector3 cameraPosition = Camera.main.transform.position; 
    Vector3 shoulderPosition = cameraPosition + Camera.main.transform.rotation * cameraShoulderOffset; 

    Vector3 indexKnucklePosition = rightHand.Fingers[1].bones[1].PrevJoint.ToVector3(); 
    Vector3 dirFromShoulder = (indexKnucklePosition - shoulderPosition).normalized; 

    Debug.DrawRay(indexKnucklePosition, dirFromShoulder, Color.white); 

    Debug.DrawLine(shoulderPosition, indexKnucklePosition, Color.red); 
    } 
} 
関連する問題