Hey all,
I have this basic problem with Unity that maybe you can help me with.
I need to get the position of the tip of my finger in "unity coordinates", this means that the position shall be the same as if I do this in a script:
using UnityEngine;
using System.Collections;
using Leap;
using LeapInternal;
using System.Collections.Generic;
public class Rotate : MonoBehaviour {
public GameObject fing_tip;
Controller LEAPcontroller;
Frame frame;
Hand hand;
List<Hand> Hands;
List<Finger> Fingers;
Vector cubeposition;
Vector3 tip_position;
Vector3 distance;
void Start()
{
LEAPcontroller = new Controller();
if (LEAPcontroller.IsConnected)
{
Debug.Log("LEAP connected!");
}
else
{
Debug.Log("LEAP is NOT connected!");
}
}
void FixedUpdate()
{
frame = LEAPcontroller.Frame();
Hands = frame.Hands;
//Debug.Log("Number of hands detected is" + Hands.Count);
if (Hands.Count == 0 || Hands.Count > 1)
{
return;
}
//Debug.Log(Hands[0].PinchDistance);
Debug.Log("leap tip" + Hands[0].Fingers[1].TipPosition);
Debug.Log("fing tip" + fing_tip.transform.position);
if (Hands[0].PinchDistance < 22f)
{
Debug.Log("pinched");
}
}
}
Where public gameobject "fing" is just "bone 3" of the index of the left hand. However, I cannot seem to get the same result with the function Hands[0].Fingers[1].TipPosition.
Researching online I found the function "toUnityScaled()", but unfortunately this function is not present in the assets of LeapMotion that I downloaded.
Do you have an answer for this problem?
Thanks,
Matteo