Nov
4
2015
4
2015
Leap Motion: Get Finger Position & Direction

Took a while to find info on how to simply get the Leap hand finger positions in unity,
here’s cleaned up script to draw rays from fingertips to their pointing direction.
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); | |
| } | |
| } | |
| } |
Related Posts
Leave a comment
Recent posts
- Adding Real World Location to Ice Fishing Prototype
- [web tool] Image Channel Inspector : AlphaScope
- Editor Tool: Smart Recompile (don’t recompile if edit comments)
- Editor Tool: Scene Size Analyzer
- LudumDare 60: Old Tech
- uBasic Scripting Language for Unity
- GreaseMonkey+Editor Plugin: 1-Click Copy script from ChatGPT (Web) to Unity Editor (as script)
- Editor Tool: Property Watcher
- .unityignore : Hide files from Project window
- PostBuild Script to Create Single exe Standalone File
- Game Loop Designer
- Favorites in PackageManager
Recent Comments
Support my work at Bags.fm:
Coin:
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
Subscribe to Blog via Email
Tag Cloud
2d
3D
AI
algorithm
android
asset
build
color
custom
demo
editor
effect
fake
free
game
generator
greasemonkey
indie
javascript
light
line
ludumdare
ludum dare
mesh
paint
particles
physics
plugin
proto
prototype
script
sea
shader
shadow
sprite
terrain
texture
tool
tutorial
ui
unity
vertex
visibility
water
waves
An article by











