Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created November 3, 2015 22:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unitycoder/575878e3b89b39378af8 to your computer and use it in GitHub Desktop.
Save unitycoder/575878e3b89b39378af8 to your computer and use it in GitHub Desktop.
Leap Motion Get Finger Positions In Unity Coordinates
/******************************************************************************\
* 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);
}
}
}
@autuus
Copy link

autuus commented Aug 7, 2018

And witch game object should have component HandModel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment