Beispiel #1
0
 //-------------------------------------------------
 void OnEnable()
 {
     if (Selection.activeTransform)
     {
         VRTRIXGloveTelportPoint teleportPoint = Selection.activeTransform.GetComponent <VRTRIXGloveTelportPoint>();
         teleportPoint.UpdateVisualsInEditor();
     }
 }
        //-------------------------------------------------
        private void TeleportPlayer()
        {
            teleporting = false;

            VRTRIXGloveTeleport.PlayerPre.Send(pointedAtTeleportMarker);

            SteamVR_Fade.Start(Color.clear, currentFadeTime);

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

            Debug.Log("teleportPosition: " + teleportPosition);
            Debug.Log("teleportPoint: " + teleportPoint);
            if (teleportPoint != null)
            {
                teleportPosition = teleportPoint.transform.position;
                Debug.Log(teleportPosition);
                //Teleport to a new scene
                if (teleportPoint.teleportType == VRTRIXGloveTelportPoint.TeleportPointType.SwitchToNewScene)
                {
                    Debug.Log("SwitchToNewScene");
                    teleportPoint.TeleportToScene();
                    return;
                }
            }

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

            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())
            {
                Debug.Log("Moving Player");
                Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess;
                Debug.Log("playerFeetOffset: " + playerFeetOffset);
                player.trackingOriginTransform.position = teleportPosition + playerFeetOffset;
                Debug.Log("trackingOriginTransform: " + player.trackingOriginTransform.position);
            }
            else
            {
                teleportingToMarker.TeleportPlayer(pointedAtPosition);
            }

            VRTRIXGloveTeleport.Player.Send(pointedAtTeleportMarker);
        }
Beispiel #3
0
        //-------------------------------------------------
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            if (Selection.activeTransform)
            {
                VRTRIXGloveTelportPoint teleportPoint = Selection.activeTransform.GetComponent <VRTRIXGloveTelportPoint>();
                if (GUI.changed)
                {
                    teleportPoint.UpdateVisualsInEditor();
                }
            }
        }
 //-------------------------------------------------
 private void CheckForSpawnPoint()
 {
     foreach (VRTRIXTeleportMarkerBase teleportMarker in teleportMarkers)
     {
         VRTRIXGloveTelportPoint teleportPoint = teleportMarker as VRTRIXGloveTelportPoint;
         if (teleportPoint && teleportPoint.playerSpawnPoint)
         {
             teleportingToMarker = teleportMarker;
             TeleportPlayer();
             break;
         }
     }
 }
        //-------------------------------------------------
        private void InitiateTeleportFade()
        {
            teleporting = true;
            //Debug.Log("Fading Start");
            currentFadeTime = teleportFadeTime;
            //Debug.Log("currentFadeTime: "  + currentFadeTime);
            VRTRIXGloveTelportPoint teleportPoint = teleportingToMarker as VRTRIXGloveTelportPoint;

            if (teleportPoint != null && teleportPoint.teleportType == VRTRIXGloveTelportPoint.TeleportPointType.SwitchToNewScene)
            {
                currentFadeTime *= 3.0f;
                VRTRIXGloveTeleport.ChangeScene.Send(currentFadeTime);
                Debug.Log("SwitchToNewScene");
            }

            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);
        }