private void RaiseTeleportInput(Vector2 teleportInput, MixedRealityInputAction teleportAction, bool isReadyForTeleport)
        {
            switch (MRTKOculusConfig.Instance.ActiveTeleportPointerMode)
            {
            case MRTKOculusConfig.TeleportPointerMode.Custom:
                if (TeleportPointer == null)
                {
                    return;
                }
                TeleportPointer.gameObject.SetActive(IsPositionAvailable);
                TeleportPointer.transform.position = currentPointerPose.Position;
                TeleportPointer.transform.rotation = currentPointerPose.Rotation;
                TeleportPointer.UpdatePointer(isReadyForTeleport, teleportInput);
                break;

            case MRTKOculusConfig.TeleportPointerMode.Official:
                if (teleportAction.Equals(MixedRealityInputAction.None))
                {
                    return;
                }
                CoreServices.InputSystem?.RaisePositionInputChanged(InputSource, ControllerHandedness, teleportAction, teleportInput);
                break;

            default:
                return;
            }
        }
Example #2
0
        private void UpdateCustomTeleportPointer(Vector3 worldPosition, Quaternion worldRotation)
        {
            if (TeleportPointer == null)
            {
                return;
            }

            // Check if we're focus locked or near something interactive to avoid teleporting unintentionally.
            bool anyPointersLockedWithHand = false;

            for (int i = 0; i < InputSource?.Pointers?.Length; i++)
            {
                if (InputSource.Pointers[i] == null)
                {
                    continue;
                }
                if (InputSource.Pointers[i] is IMixedRealityNearPointer)
                {
                    var nearPointer = (IMixedRealityNearPointer)InputSource.Pointers[i];
                    anyPointersLockedWithHand |= nearPointer.IsNearObject;
                }
                anyPointersLockedWithHand |= InputSource.Pointers[i].IsFocusLocked;
            }

            // We close middle finger to signal spider-man gesture, and as being ready for teleport
            bool isReadyForTeleport = !anyPointersLockedWithHand && IsPositionAvailable && !IsInPointingPose &&
                                      isMiddleGrabbing;


            Vector2 stickInput = isReadyForTeleport ? Vector2.up : Vector2.zero;

            TeleportPointer.gameObject.SetActive(isReadyForTeleport);
            TeleportPointer.transform.position = worldPosition;
            TeleportPointer.transform.rotation = worldRotation;

            TeleportPointer.UpdatePointer(isReadyForTeleport, isIndexGrabbing ? Vector2.zero : stickInput);
        }