Skip to content

Commit faa4310

Browse files
committed
Fixing a bug where the teleport location was not accurate after a rotation.
Also, printed an error if the FadeScript doesn't exist in the scene.
1 parent cd71a22 commit faa4310

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Assets/HoloToolkit/Input/Scripts/Gaze/MixedRealityTeleport.cs

+9-4
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,19 @@ public class MixedRealityTeleport : Singleton<MixedRealityTeleport>, IController
4949

5050
private void Start()
5151
{
52-
if (!XRDevice.isPresent)
52+
fadeControl = FadeScript.Instance;
53+
54+
if (!XRDevice.isPresent || fadeControl == null)
5355
{
56+
if (fadeControl == null)
57+
{
58+
Debug.LogError("The MixedRealityTeleport script on " + name + " requires a FadeScript object.");
59+
}
60+
5461
Destroy(this);
5562
return;
5663
}
5764

58-
fadeControl = FadeScript.Instance;
59-
6065
teleportMarker = Instantiate(TeleportMarker);
6166
teleportMarker.SetActive(false);
6267

@@ -247,7 +252,7 @@ public void SetWorldPosition(Vector3 worldPosition)
247252
// and the user's head (which the MR device is attached to. :)). When setting the world position,
248253
// we need to set it relative to the user's head in the scene so they are looking/standing where
249254
// we expect.
250-
transform.position = worldPosition - Camera.main.transform.localPosition;
255+
transform.position = worldPosition - (Camera.main.transform.position - transform.position);
251256
}
252257

253258
private void EnableMarker()

0 commit comments

Comments
 (0)