public void DoTeleport() { if (teleported) { return; } teleported = true; if (!targetRotation) { targetRotation = target; } // Force enabling the teleport target.tag = "IncludeTeleport"; bool scaleRoom = sceneObjects && newSceneScale > 0; var teleportPosition = (target.position * (scaleRoom && scalePosition ? newSceneScale : 1)) + offset; var teleporter = this.teleporter ?? FindObjectOfType <VRTK_BasicTeleport>(); var playAreaTeleport = teleporter as PlayAreaLimitedTeleport; bool originalCheckForCollisiosn = false; if (playAreaTeleport) { originalCheckForCollisiosn = playAreaTeleport.checkForCollisions; playAreaTeleport.checkForCollisions = false; } var originalBlinkDelay = teleporter.distanceBlinkDelay; var originalBlinkTransition = teleporter.blinkTransitionSpeed; teleporter.distanceBlinkDelay = blinkDistance; teleporter.blinkTransitionSpeed = blinkTransition; if (scaleRoom) { sceneObjects.localScale = new Vector3(newSceneScale, newSceneScale, newSceneScale); } Quaternion?rotation = null; if (doRotate) { float rotationY; if (VRTK_DeviceFinder.GetHeadsetTypeAsString() == "simulator") { // The simulator Y rotation is done by the play area and not the headset transform... rotationY = Vector3.SignedAngle(Vector3.forward, targetRotation.forward, Vector3.up); } else { rotationY = VectorUtils.AngleOffAroundAxis(targetRotation.forward, VRTK_DeviceFinder.HeadsetTransform().forward, Vector3.up) + VRTK_SDKManager.instance.transform.rotation.eulerAngles.y; } rotation = Quaternion.Euler(0, rotationY, 0); } beforeTeleport?.Invoke(); if (scaleCamera && resizeFirst) { VRTK_SDKManager.instance.transform.localScale = new Vector3(newSceneScale, newSceneScale, newSceneScale); } if (doTeleport) { teleporter.Teleport(target, teleportPosition, rotation); } else { VRTK_SDK_Bridge.HeadsetFade(Color.black, 0); teleporter.Invoke("ReleaseBlink", 1.0f); } if (scaleCamera && !resizeFirst) { VRTK_SDKManager.instance.transform.localScale = new Vector3(newSceneScale, newSceneScale, newSceneScale); } afterTeleport?.Invoke(); if (deleteTarget) { Destroy(target.gameObject); } teleporter.distanceBlinkDelay = originalBlinkDelay; teleporter.blinkTransitionSpeed = originalBlinkTransition; if (playAreaTeleport) { playAreaTeleport.checkForCollisions = originalCheckForCollisiosn; } }