private void Update() { HandController hand = GetComponentInParent <HandController>(); if (!targetHand) { if (hand) { targetHand = hand.oppositeHand.currentHand.GetComponent <TwoHandedGuidingHand>(); } if (!targetHand) { return; } } if (twoHandedAimActive && targetHand.guidingTransform) { guidingVector = targetHand.guidingTransform.position - guide.position; float angleBetweenHands = Vector3.Angle(guide.forward, guidingVector); isHandWithinRange = angleBetweenHands <= snapAngle; } else if (isHandWithinRange) { isHandWithinRange = false; objectToGuide.rotation = originalRotation; } if (isHandWithinRange) { objectToGuide.rotation = Quaternion.LookRotation(guidingVector, guide.up); if (!objectToEnableWhenTwoHanded.activeSelf) { objectToEnableWhenTwoHanded.SetActive(true); targetHand.objectToDisableWhenTwoHanded.SetActive(false); } } else { if (objectToGuide.localRotation != originalRotation) { objectToGuide.localRotation = originalRotation; } if (objectToEnableWhenTwoHanded.activeSelf) { objectToEnableWhenTwoHanded.SetActive(false); targetHand.objectToDisableWhenTwoHanded.SetActive(true); } } if (parentHand && parentHand.stabilisePosition != isHandWithinRange) { parentHand.stabilisePosition = isHandWithinRange; } }
private static void SetupHands() { HandController leftHand = GameObject.Instantiate(handControllerPrefab).GetComponent <HandController>(); leftHand.xrNode = XRNode.LeftHand; Vector3 mirroredScale = leftHand.transform.localScale; mirroredScale.x = -mirroredScale.x; leftHand.transform.localScale = mirroredScale; HandController rightHand = GameObject.Instantiate(handControllerPrefab).GetComponent <HandController>(); rightHand.xrNode = XRNode.RightHand; dominantHand = ModConfig.LeftDominantHand.Value ? leftHand : rightHand; nonDominantHand = ModConfig.LeftDominantHand.Value ? rightHand : leftHand; dominantHand.SetPrefabs(handPrefabs.Where((x) => CheckDominance(x, true)).ToList()); nonDominantHand.SetPrefabs(handPrefabs.Where((x) => CheckDominance(x, false)).ToList()); dominantHand.oppositeHand = nonDominantHand; nonDominantHand.oppositeHand = dominantHand; }
private void Awake() { parentHand = GetComponentInParent <HandController>(); originalRotation = objectToGuide.localRotation; }
private void Awake() { parentHand = GetComponentInParent <HandController>(); }