//------------------------------------------------- private void TeleportPlayer() { teleporting = false; PlayerPre.Send(pointedAtTeleportMarker); SteamVR_Fade.Start(Color.clear, currentFadeTime); TeleportPoint_NVR teleportPoint = teleportingToMarker as TeleportPoint_NVR; Vector3 teleportPosition = pointedAtPosition; if (teleportPoint != null) { teleportPosition = teleportPoint.transform.position; //Teleport to a new scene if (teleportPoint.teleportType == TeleportPoint_NVR.TeleportPointType.SwitchToNewScene) { teleportPoint.TeleportToScene(); return; } } // Find the actual floor position below the navigation mesh TeleportArea_NVR teleportArea = teleportingToMarker as TeleportArea_NVR; 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.transform.position - FeetPositionEstimate(); player.transform.position = teleportPosition + playerFeetOffset; } else { teleportingToMarker.TeleportPlayer(pointedAtPosition); } Player.Send(pointedAtTeleportMarker); }
//------------------------------------------------- private void InitiateTeleportFade() { teleporting = true; currentFadeTime = teleportFadeTime; TeleportPoint_NVR teleportPoint = teleportingToMarker as TeleportPoint_NVR; if (teleportPoint != null && teleportPoint.teleportType == TeleportPoint_NVR.TeleportPointType.SwitchToNewScene) { currentFadeTime *= 3.0f; ChangeScene.Send(currentFadeTime); } SteamVR_Fade.Start(Color.clear, 0); SteamVR_Fade.Start(Color.black, currentFadeTime); headAudioSource.transform.SetParent(player.Head.transform); headAudioSource.transform.localPosition = Vector3.zero; PlayAudioClip(headAudioSource, teleportSound); Invoke("TeleportPlayer", currentFadeTime); }