예제 #1
0
        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;
            }
        }
예제 #2
0
        private void UpdateTeleport()
        {
            MixedRealityInputAction teleportAction  = MixedRealityInputAction.None;
            TeleportPointer         teleportPointer = null;

            // 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;

                // If official teleport mode and we have a teleport pointer registered, we get the input action to trigger it.
                if (InputSource.Pointers[i] is IMixedRealityTeleportPointer)
                {
                    teleportPointer = (TeleportPointer)InputSource.Pointers[i];
                    teleportAction  = teleportPointer.TeleportInputAction;
                }
            }

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

            // Tracks the input vector that should be sent out based on the gesture that is made
            Vector2 stickInput = (isReadyForTeleport && !isIndexGrabbing) ? Vector2.up : Vector2.zero;

            // The teleport event needs to be canceled if we have not completed the teleport motion and we were previously ready to teleport, but for some reason we
            // are no longer doing the ready to teleport gesture
            bool teleportCanceled = previousReadyToTeleport && !isReadyForTeleport && !isIndexGrabbing;

            if (teleportCanceled && teleportPointer != null)
            {
                CoreServices.TeleportSystem?.RaiseTeleportCanceled(teleportPointer, null);
                previousStickInput      = stickInput;
                previousReadyToTeleport = isReadyForTeleport;
                return;
            }

            bool teleportInputChanged = stickInput != previousStickInput;

            if (teleportInputChanged)
            {
                RaiseTeleportInput(stickInput, teleportAction);
            }

            previousStickInput      = stickInput;
            previousReadyToTeleport = isReadyForTeleport;
        }