Exemplo n.º 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();
            }
        }
Exemplo n.º 2
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())
                {
                    //if player is not ready for teleport then return
                    if (Player.instance.currentState != Player.PlayerState.None)
                    {
                        return;
                    }
                    StartTeleportSelection();
                }
            }

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

            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;
            }
            Vector3 nextPlayerPosition = Vector3.zero;

            // When trigger deactivates we finish the teleport.
            if (selectionIsActive && teleportCommitTrigger.TriggerActive())
            {
                if (selectionResult.selectionIsValid)
                {
                    detector.EndSelection();
                    visualizer.EndSelection();


                    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);
                    if (Player.instance.visualPlayer)
                    {
                        Player.instance.visualPlayer.transform.DOMove(nextPlayerPosition, 1f);
                    }
                    player.DOMove(nextPlayerPosition, 1f).OnComplete(() => { EndTeleportSelection(); });
                }

                //    EndTeleportSelection();
            }
        }
Exemplo n.º 3
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();
            }
        }