ユニティで人差し指を十字線をコントロールするために使用している照準システムを作成しようとしています。ゲームはOculusで行われており、Leap MotionはOculusヘッドセットに搭載されています。LeapMotion + Unity:指の角度に基づいて3次元世界のオブジェクトを移動する
私は人差し指の角度に基づいて十字線の位置を計算し、与えられた距離に基づいて光線を描こうとしました。私は、また、ちょうどこのような人差し指と所定の距離の方向に基づいて、十字の位置を計算しようとしている:
void Start() {
crossHair = GameObject.Find("Crosshair Component");
myCamera = GameObject.Find("CenterEyeAnchor");
target = crossHair.transform;
controller = new Controller();
indexFinger = new Finger();
void Update() {
crossHair.transform.position = myCamera.transform.position;
frame = controller.Frame();
List<Hand> handList = new List<Hand>();
for (int h = 0; h < frame.Hands.Count; h++)
{
Hand leapHand = frame.Hands[h];
handList.Add(leapHand);
}
if (handList != null && frame.Hands.Count > 0) {
indexFinger = frame.Hands[0].Fingers[(int)Finger.FingerType.TYPE_INDEX];
if (indexFinger.IsExtended)
{
Vector3 fingerTipPos = indexFinger.TipPosition.ToUnityScaled();
Vector3 originAngle = indexFinger.TipPosition.ToUnityScaled();
Vector3 targetAngle = crossHair.transform.position;
float distance = 1;
Vector3 direction = indexFinger.Direction.ToUnityScaled();
Ray rayToTest = new Ray(originAngle, targetAngle);
Vector3 targetPoint = rayToTest.GetPoint(distance);
//Problem is here. How should these targetPoint values be used to calculate correct position for the crosshair?
crossHair.transform.position = new Vector3(crossHair.transform.position.x + (targetPoint.x), y,
crossHair.transform.position.z + (targetPoint.z));
}
}
}
}
との:ここ
Vector3 targetPoint = direction * direction;
私が試みたものです私はxとzの値を変更することによって水平方向に十字線を移動することができましたが、y軸は最大の問題と思われます。 Y軸は常に低すぎる値を受け取っているようです。 Crosshair要素は、UnityのCenterEyeAnchorカメラオブジェクトの子要素として配置されます。
質問には次のようなものがあります。ターゲットポイントの位置を計算しようとしていますか? 人差し指の動きに応じて動作させるために、新しい目標点の値に基づいて十字線の位置に対してどのような計算を行う必要がありますか?値のスケーリング係数?
私は非常にオクルスに精通し、飛躍に精通んだけど、あなたは、オブジェクトの設定を示すスクリーンショットのいくつかの並べ替えを含まない限り、それは助けることはほぼ不可能です。現在何がどこにあるかを知ることは絶対に不可能です。 – Fattie