Hi every one i was working on something same like this but what i need to do is get position of the index finger and set that position equal to some other object's/asset's position in the scene.I get the position with the code that you have mentioned here but the position values are different which appear in the inspector and in console when i debug these values and so is the position of the object is not the same as of my hands in the game environment.
What i want is to place that scissor in this game environment on my index finger moves away due to the different position values.
please guide me where i am wrong i am new to leap-motion and unity.
Thanks
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Leap;
using Leap.Unity;
public class movement : MonoBehaviour {
Controller controller;
float HandPalmPitch;
float HandPalmYan;
float HandPalmRoll;
float HandWristRot;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
controller = new Controller();
Frame frame = controller.Frame();
List<Hand> hands = frame.Hands;
if (frame.Hands.Count > 0)
{
Hand firstHand = hands[0];
Finger index = frame.Hands[0].Fingers[(int)Finger.FingerType.TYPE_INDEX];
HandPalmPitch = hands[0].PalmNormal.Pitch;
HandPalmRoll = hands[0].PalmNormal.Roll;
HandPalmYan = hands[0].PalmNormal.Yaw;
HandWristRot = hands[0].WristPosition.Pitch;
transform.rotation = hands[0].Rotation.ToQuaternion();
//transform.position = hands[0].PalmPosition.ToVector3();
//print(hands[0].PalmPosition.ToVector3().ToString());
//print("Quaternion="+Quaternion.Euler( hands[0].PalmPosition.ToVector3()));
Vector3 position = index.TipPosition.ToVector3();
transform.position = position;
print("Coordinates: " + index.TipPosition.ToVector3().ToString());
}
}
}