代码比较简单,我就不解释了
1.结构图如下:
2.代码如下:
using System.Collections;
using System.Collections.Generic;
using Leap;
using Leap.Unity;
using UnityEngine;
public class CcreateCube : MonoBehaviour {
public HandModelBase leftHandModel;
public HandModelBase rightHandModel;
float twoFingerDistance = 0.07f;
// 1.判断两个手指捏合
// 2.判断两个手靠近
// 3.生成cube
// Update is called once per frame
void Update () {
if (leftHandModel.IsTracked)
{
Hand leftHand = leftHandModel.GetLeapHand();
// float twoFingerDistance = 0.07f;
if ((leftHand.Fingers[0].TipPosition - leftHand.Fingers[1].TipPosition).Magnitude < twoFingerDistance)
{
print("卧槽尼玛 你靠那么近干嘛!");
}
}
}
}