public void EnableTouchInput(HumanoidControl humanoid, bool isLeft, float autoActivation) { if (humanoid.avatarRig == null) { return; } if (pointers == null) { pointers = new InteractionPointer[maxInteractions]; // 0 = left index, 1 = right index, 2 = head, 3 = controller } Controller controllerInput = Controllers.GetController(0); Transform indexFingerDistal = null; Transform indexFingerTip = null; InteractionPointer pointer = null; if (isLeft) { indexFingerDistal = humanoid.avatarRig.GetBoneTransform(HumanBodyBones.LeftIndexDistal); if (indexFingerDistal != null) { if (indexFingerDistal.childCount == 1) { indexFingerTip = indexFingerDistal.GetChild(0); } else { indexFingerTip = indexFingerDistal; } pointer = new InteractionPointer(PointerType.Touch, indexFingerTip, eventSystem); pointers[(int)InputDeviceIDs.LeftHand] = pointer; if (controllerInput != null) { pointer.controllerInputSide = controllerInput.left; } } } else { indexFingerDistal = humanoid.avatarRig.GetBoneTransform(HumanBodyBones.RightIndexDistal); if (indexFingerDistal != null) { if (indexFingerDistal.childCount == 1) { indexFingerTip = indexFingerDistal.GetChild(0); } else { indexFingerTip = indexFingerDistal; } pointer = new InteractionPointer(PointerType.Touch, indexFingerTip, eventSystem); pointers[(int)InputDeviceIDs.RightHand] = pointer; if (controllerInput != null) { pointer.controllerInputSide = controllerInput.right; } } } if (indexFingerDistal != null) { if (indexFingerDistal.childCount > 0) { indexFingerTip = indexFingerDistal.GetChild(0); pointer.localPointingDirection = indexFingerTip.InverseTransformDirection(indexFingerTip.position - indexFingerDistal.position).normalized; } else { pointer.localPointingDirection = indexFingerDistal.InverseTransformDirection(indexFingerDistal.position - indexFingerDistal.parent.position).normalized; } } if (pointer != null) { pointer.focusTimeToTouch = autoActivation; // To support hovering pointer.focusingEnabled = true; } }
public Controller SetControllerID(int controllerID) { InitAxis(controllerID); controller = Controllers.GetController(controllerID); return(controller); }
public override void Start(HumanoidControl _humanoid, Transform targetTransform) { base.Start(_humanoid, targetTransform); sensorID = handTarget.isLeft ? Sensor.ID.LeftHand : Sensor.ID.RightHand; controllerInput = Controllers.GetController(0); }