Ejemplo n.º 1
0
        // Update is called once per frame
        void LateUpdate()
        {
            bool headColliding = false;

            // Checl for Head Collisions if hmd equipped
            if (OVRManager.hasVrFocus)
            {
                for (int x = 0; x < collisions.Count; x++)
                {
                    if (collisions[x] != null && collisions[x].enabled)
                    {
                        headColliding = true;
                        break;
                    }
                }
            }

            if (headColliding)
            {
                FadeDistance = Vector3.Distance(transform.position, DistanceTransform.position);
            }
            else
            {
                FadeDistance = 0;
            }


            if (fader)
            {
                // Too far away, fade to black
                if (FadeDistance > FadeOutDistance)
                {
                    currentFade += Time.deltaTime * FadeSpeed;

                    if (headColliding && currentFade < MinFade)
                    {
                        currentFade = MinFade;
                    }

                    if (currentFade > MaxFade)
                    {
                        currentFade = MaxFade;
                    }

                    fader.SetFadeLevel(currentFade);
                }
                // Fade back
                else
                {
                    currentFade -= Time.deltaTime * FadeSpeed;

                    if (currentFade < 0)
                    {
                        currentFade = 0;
                    }

                    fader.SetFadeLevel(currentFade);
                }
            }
        }
    /// <summary>
    /// This coroutine will fade out the view, perform the teleport, and then fade the view
    /// back in.
    /// </summary>
    /// <returns></returns>
    protected IEnumerator BlinkCoroutine()
    {
        LocomotionTeleport.IsTransitioning = true;
        float elapsedTime  = 0;
        var   teleportTime = TransitionDuration * TeleportDelay;
        var   teleported   = false;

        while (elapsedTime < TransitionDuration)
        {
            yield return(null);

            elapsedTime += Time.deltaTime;
            if (!teleported && elapsedTime >= teleportTime)
            {
                teleported = true;
                LocomotionTeleport.DoTeleport();
            }
            float fadeLevel = FadeLevels.Evaluate(elapsedTime / TransitionDuration);
            fader.SetFadeLevel(fadeLevel);
        }

        fader.SetFadeLevel(0);

        LocomotionTeleport.IsTransitioning = false;
    }
Ejemplo n.º 3
0
    public IEnumerator FadeTeleport(Vector3 destination)
    {
        float elapsedTime = 0;
        bool  teleported  = false;

        while (elapsedTime < m_transitionTime)
        {
            yield return(null);

            elapsedTime += Time.deltaTime;
            if (!teleported && elapsedTime >= m_transitionTime * 0.5f)
            {
                teleported = true;
                m_characterController.enabled = false;
                m_charTransform.position      = destination;
                m_characterController.enabled = true;
            }
            float fadeLevel = FadeLevels.Evaluate(elapsedTime / m_transitionTime);
            m_screenFader.SetFadeLevel(fadeLevel);
        }
        m_locomotionIndicator.ResetStatus();

        m_screenFader.SetFadeLevel(0);
        foreach (Rigidbody rb in m_rbs)
        {
            rb.isKinematic = m_originalKinStat[rb.gameObject.GetInstanceID()];
        }
        m_isTeleporting = false;
    }
Ejemplo n.º 4
0
    public void TeleportPlayer(GameObject teleportPoint)
    {
        // Add last active teleport point back to the list of available points
        if (activeTeleportPoint != null)
        {
            teleportPoints.Add(activeTeleportPoint);
        }

        // Set and remove the selected point
        activeTeleportPoint = teleportPoint;
        teleportPoints.Remove(teleportPoint);


        // Move the player transform to the desired location
        Vector3 newPosition = teleportPoint.transform.position;

        if (gameState == GameState.Boot)
        {
            sF.SetFadeLevel(1);
            player.transform.position = newPosition;
            sF.FadeIn();
        }
        else
        {
            StartCoroutine(PlayerTransition(newPosition));
        }

        RefreshDisplays();
    }
Ejemplo n.º 5
0
        public void FixedUpdate()
        {
            if (trackedColliders.Count == 0)
            {
                return;
            }

            ovrScreenFade.SetFadeLevel(GetFadeLevel());
        }