diff --git a/Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs b/Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs index 7a9c4139e8c..1cd7603c3b8 100644 --- a/Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs +++ b/Assets/HoloToolkit/Input/Scripts/Utilities/Managers/MixedRealityTeleport.cs @@ -216,28 +216,25 @@ public void StartTeleport() } } - private void FinishTeleport() - { - if (currentPointingSource != null) - { - currentPointingSource = null; - - if (isTeleportValid) - { - RaycastHit hitInfo; - Vector3 hitPos = teleportMarker.transform.position + Vector3.up * (Physics.Raycast(CameraCache.Main.transform.position, Vector3.down, out hitInfo, 5.0f) ? hitInfo.distance : 2.6f); - - fadeControl.DoFade(0.25f, 0.5f, () => - { - SetWorldPosition(hitPos); - }, null); - } - - DisableMarker(); - } - } - - public void DoRotation(float rotationAmount) + private void FinishTeleport() + { + if (currentPointingSource != null) + { + currentPointingSource = null; + + if (isTeleportValid) + { + fadeControl.DoFade(0.25f, 0.5f, () => + { + SetWorldPosition(teleportMarker.transform.position); + }, null); + } + + DisableMarker(); + } + } + + public void DoRotation(float rotationAmount) { if (rotationAmount != 0 && !fadeControl.Busy) { @@ -267,20 +264,22 @@ public void DoStrafe(Vector3 strafeAmount) } } - /// - /// Places the player in the specified position of the world - /// - /// - public void SetWorldPosition(Vector3 worldPosition) - { - // There are two things moving the camera: the camera parent (that this script is attached to) - // and the user's head (which the MR device is attached to. :)). When setting the world position, - // we need to set it relative to the user's head in the scene so they are looking/standing where - // we expect. - transform.position = worldPosition - (CameraCache.Main.transform.position - transform.position); - } - - private void EnableMarker() + /// + /// Places the player in the specified position of the world + /// + /// + public void SetWorldPosition(Vector3 worldPosition) + { + // There are two things moving the camera: the camera parent (that this script is attached to) + // and the user's head (which the MR device is attached to. :)). When setting the world position, + // we need to set it relative to the user's head in the scene so they are looking/standing where + // we expect. + Vector3 newPosition = worldPosition - (CameraCache.Main.transform.position - transform.position); + newPosition.y = worldPosition.y; + transform.position = newPosition; + } + + private void EnableMarker() { teleportMarker.SetActive(true); if (animationController != null)