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
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
- Detect SRP (URP or HDRP) with Assembly Definition Version Defines
- [LudumDare57] Theme: Depths
- MotionVector Effect: Object “disappears” when paused
Recent Comments
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
- on [Asset Store] Point Cloud Viewer & Tools
- on [Asset Store] Point Cloud Viewer & Tools
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
error
fake
free
game
generator
greasemonkey
indie
javascript
light
line
ludumdare
mesh
paint
particles
physics
plugin
proto
prototype
script
sea
shader
shadow
sprite
terrain
texture
tutorial
ui
unity
vertex
visibility
water
waves
webgl
An article by











