From 904aeebd45bef3171f7f3174f5a0ab0b974cfa37 Mon Sep 17 00:00:00 2001 From: "USER-PC\\Alexander Seeck" Date: Tue, 14 Nov 2017 18:32:37 +0100 Subject: [PATCH] Fixes the problem with accumulating teleportation heights #1181 The MixedRealityCameraParent changed heights based on a raycast from the head to the floor. Depending on where the camera is in relation to the parent, the parent's base height shrank or grew. The head raycast howere is not needed and removed since the relative distance to the cameraParent is always controlled via HDM and the target teleport position for the parent is always known. --- .../Managers/MixedRealityTeleport.cs | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) 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)