private void updateForHand(Leap.Hand hand, GrabSwitch grabSwitch, ref float lastPinchStrength, ref bool switchWithinRange, InteractionHand optionalIntHand) { if (hand == null) { grabSwitch.grasped = false; lastPinchStrength = 0.0f; return; } var curPinchStrength = hand.PinchStrength; var curPinchPosition = hand.GetPredictedPinchPosition(); switchWithinRange = Vector3.Distance(curPinchPosition, this.transform.position) < _widgetRadius && (optionalIntHand == null || (!optionalIntHand.isGraspingObject && (!optionalIntHand.isPrimaryHovering || optionalIntHand.primaryHoverDistance > 0.05f))); if (curPinchStrength > 0.7f && lastPinchStrength < 0.7f && switchWithinRange) { grabSwitch.grasped = true; } if (curPinchStrength < 0.3f) { grabSwitch.grasped = false; } grabSwitch.Position = curPinchPosition; grabSwitch.Rotation = hand.Rotation.ToQuaternion(); lastPinchStrength = hand.PinchStrength; }