Esempio n. 1
0
 //-------------------------------------------------
 void OnEnable()
 {
     if (Selection.activeTransform)
     {
         TeleportPoint teleportPoint = Selection.activeTransform.GetComponent <TeleportPoint>();
         teleportPoint.UpdateVisualsInEditor();
     }
 }
Esempio n. 2
0
        //-------------------------------------------------
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            if (Selection.activeTransform)
            {
                TeleportPoint teleportPoint = Selection.activeTransform.GetComponent <TeleportPoint>();
                if (GUI.changed)
                {
                    teleportPoint.UpdateVisualsInEditor();
                }
            }
        }
Esempio n. 3
0
 //-------------------------------------------------
 private void CheckForSpawnPoint()
 {
     foreach (TeleportMarkerBase teleportMarker in teleportMarkers)
     {
         TeleportPoint teleportPoint = teleportMarker as TeleportPoint;
         if (teleportPoint && teleportPoint.playerSpawnPoint)
         {
             teleportingToMarker = teleportMarker;
             TeleportPlayer();
             break;
         }
     }
 }
Esempio n. 4
0
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            Teleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

            TeleportPoint teleportPoint    = teleportingToMarker as TeleportPoint;
            Vector3       teleportPosition = pointedAtPosition;

            if (teleportPoint != null)
            {
                teleportPosition = teleportPoint.transform.position;

                //Teleport to a new scene
                if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
                {
                    teleportPoint.TeleportToScene();
                    return;
                }
            }

            // Find the actual floor position below the navigation mesh
            TeleportArea teleportArea = teleportingToMarker as TeleportArea;

            if (teleportArea != null)
            {
                if (floorFixupMaximumTraceDistance > 0.0f)
                {
                    RaycastHit raycastHit;
                    if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask))
                    {
                        teleportPosition = raycastHit.point;
                    }
                }
            }

            if (teleportingToMarker.ShouldMovePlayer())
            {
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;
            }
            else
            {
                teleportingToMarker.TeleportPlayer(pointedAtPosition);
            }

            Teleport.Player.Send(pointedAtTeleportMarker);
        }
Esempio n. 5
0
        //-------------------------------------------------
        private void InitiateTeleportFade()
        {
            teleporting = true;

            currentFadeTime = teleportFadeTime;

            TeleportPoint teleportPoint = teleportingToMarker as TeleportPoint;

            if (teleportPoint != null && teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene)
            {
                currentFadeTime *= 3.0f;
                Teleport.ChangeScene.Send(currentFadeTime);
            }

            SteamVR_Fade.Start(Color.clear, 0);
            SteamVR_Fade.Start(Color.black, currentFadeTime);

            headAudioSource.transform.SetParent(player.hmdTransform);
            headAudioSource.transform.localPosition = Vector3.zero;
            PlayAudioClip(headAudioSource, teleportSound);

            Invoke("TeleportPlayer", currentFadeTime);
        }