Created
November 3, 2015 22:33
-
-
Save unitycoder/575878e3b89b39378af8 to your computer and use it in GitHub Desktop.
Leap Motion Get Finger Positions In Unity Coordinates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************\ | |
* Copyright (C) Leap Motion, Inc. 2011-2014. * | |
* Leap Motion proprietary. Licensed under Apache 2.0 * | |
* Available at http://www.apache.org/licenses/LICENSE-2.0.html * | |
\******************************************************************************/ | |
// Original script: "MagneticPinch.cs" modified by unitycoder.com to just get the finger position & directions | |
using UnityEngine; | |
using System.Collections; | |
using Leap; | |
public class GetLeapFingers : MonoBehaviour | |
{ | |
HandModel hand_model; | |
Hand leap_hand; | |
void Start() | |
{ | |
hand_model = GetComponent<HandModel>(); | |
leap_hand = hand_model.GetLeapHand(); | |
if (leap_hand == null) Debug.LogError("No leap_hand founded"); | |
} | |
void Update() | |
{ | |
for (int i = 0; i < HandModel.NUM_FINGERS;i++) | |
{ | |
FingerModel finger = hand_model.fingers[i]; | |
// draw ray from finger tips (enable Gizmos in Game window to see) | |
Debug.DrawRay(finger.GetTipPosition(), finger.GetRay().direction, Color.red); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And witch game object should have component HandModel?