예제 #1
0
        void Update()
        {
            if (IsConfigured() == false)
            {
                return;
            }

            currentController = GetControllerTransform();

            // Complete active teleport transitions.
            if (IsTeleporting)
            {
                visualizer.OnTeleport();
                // Update the visualization.
                visualizer.UpdateSelection(currentController, selectionResult);
                return;
            }

            // If rotation is allowed, handle player rotations.
            if (allowRotation)
            {
                HandlePlayerRotations();
            }

            // If a teleport selection session has not started, check the appropriate
            // trigger to see if one should start.
            if (selectionIsActive == false)
            {
                if (teleportStartTrigger.TriggerActive())
                {
                    StartTeleportSelection();
                }
            }

            // Get the current selection result from the detector.
            float playerHeight = DetectPlayerHeight();

            selectionResult = detector.DetectSelection(currentController, playerHeight);

            // Update the visualization.
            visualizer.UpdateSelection(currentController, selectionResult);

            // If not actively teleporting, just return.
            if (selectionIsActive == false)
            {
                return;
            }

            // Check for the optional cancel trigger.
            if (teleportCancelTrigger != null &&
                teleportCancelTrigger.TriggerActive() &&
                !teleportCommitTrigger.TriggerActive())
            {
                EndTeleportSelection();
                return;
            }

            // When trigger deactivates we finish the teleport.
            if (selectionIsActive && teleportCommitTrigger.TriggerActive())
            {
                if (selectionResult.selectionIsValid)
                {
                    Vector3 nextPlayerPosition = new Vector3(
                        selectionResult.selection.x,
                        selectionResult.selection.y + playerHeight,
                        selectionResult.selection.z);

                    // Start a transition to move the player.
                    transition.StartTransition(
                        player,
                        currentController,
                        nextPlayerPosition);
                }

                EndTeleportSelection();
            }
        }
예제 #2
0
        void Update()
        {
            if (IsConfigured() == false)
            {
                return;
            }

            // Ignore everything until teleport transition completes.
            if (IsTeleporting)
            {
                return;
            }

            // No teleport session started yet, let's check our triggers.
            if (selectionIsActive == false)
            {
                if (teleportStartTrigger.TriggerActive())
                {
                    selectionIsActive = true;
                    StartTeleportSelection();
                }
            }

            // Always process rotations until complete.
            if (allowRotation && HandlePlayerRotations())
            {
                return;
            }

            // If not actively teleporting, just return.
            if (selectionIsActive == false)
            {
                return;
            }

            // Check for the optional cancel trigger.
            if (teleportCancelTrigger != null &&
                teleportCancelTrigger.TriggerActive() &&
                !teleportCommitTrigger.TriggerActive())
            {
                EndTeleportSelection();
                return;
            }

            Transform currentController = GetControllerTransform();

            // Detect the teleport selection, and if it's valid for moving to.
            BaseTeleportDetector.Result selectionResult =
                detector.DetectSelection(currentController);

            // Update the visualization.
            visualizer.UpdateSelection(currentController, selectionResult);

            // When trigger deactivates we finish the teleport.
            if (selectionIsActive && teleportCommitTrigger.TriggerActive())
            {
                if (selectionResult.selectionIsValid)
                {
                    float playerHeight = DetectPlayersHeight();

                    Vector3 nextPlayerPosition = new Vector3(
                        selectionResult.selection.x,
                        selectionResult.selection.y + playerHeight,
                        selectionResult.selection.z);

                    // Start a transition to move the player.
                    transition.StartTransition(
                        player,
                        currentController,
                        nextPlayerPosition);
                }

                EndTeleportSelection();
            }
        }