private bool displayActive = false; // don't update path when it's false. // Teleport target transform to ground position public void Teleport() { if (groundDetected && canTeleport) { if (EndZone.ClosestPoint(groundPos) == groundPos) { EndZone.gameObject.GetComponent <TriggerNextLevel>().Load(); } bodyTransform.position = groundPos + lastNormal * 0.1f; if (lastCubeTarget != null) { lastCubeTarget.Detach(bodyTransform.gameObject); lastCubeTarget = null; } if (cubeTarget != null) { cubeTarget.ApplyCollision(bodyTransform.gameObject); lastCubeTarget = cubeTarget; } } else { Debug.Log("Ground wasn't detected"); } }
//------------------------------------------------- private void TeleportPlayer() { teleporting = false; Teleport.PlayerPre.Send(pointedAtTeleportMarker); SteamVR_Fade.Start(Color.clear, currentFadeTime); TeleportPoint teleportPoint = teleportingToMarker as TeleportPoint; Vector3 teleportPosition = pointedAtPosition; if (teleportPoint != null) { Debug.Log("Was a teleport point"); teleportPosition = teleportPoint.transform.position; //Teleport to a new scene if (teleportPoint.teleportType == TeleportPoint.TeleportPointType.SwitchToNewScene) { teleportPoint.TeleportToScene(); return; } } // Find the actual floor position below the navigation mesh TeleportArea teleportArea = teleportingToMarker as TeleportArea; CubeType cube = null; if (teleportArea != null) { Debug.Log("Was a teleport area"); if (floorFixupMaximumTraceDistance > 0.0f) { RaycastHit raycastHit; if (Physics.Raycast(teleportPosition + 0.05f * Vector3.down, Vector3.down, out raycastHit, floorFixupMaximumTraceDistance, floorFixupTraceLayerMask)) { teleportPosition = raycastHit.point; } GameObject target = teleportArea.gameObject.transform.parent.gameObject; Debug.Log("teleporting to teleport area: " + target.name); cube = target.GetComponent <CubeType>(); Debug.Log("Did it have a float cube? " + cube); foreach (Component obj in target.GetComponents(typeof(Component))) { Debug.Log("Component in " + target + ": " + obj); } } } if (teleportingToMarker.ShouldMovePlayer()) { Debug.Log("if ( teleportingToMarker.ShouldMovePlayer() )"); Vector3 playerFeetOffset = player.trackingOriginTransform.position - player.feetPositionGuess; player.trackingOriginTransform.position = teleportPosition + playerFeetOffset; if (platform != null) { if (platform.GetComponent <CubeType>() != null) { platform.GetComponent <CubeType>().Detach(GameObject.Find("Player")); } platform = null; } if (cube != null) { Debug.Log("Raycast hit float cube"); cube.ApplyCollision(GameObject.Find("Player")); platform = cube.gameObject; } if (player.leftHand.currentAttachedObjectInfo.HasValue) { player.leftHand.ResetAttachedTransform(player.leftHand.currentAttachedObjectInfo.Value); } if (player.rightHand.currentAttachedObjectInfo.HasValue) { player.rightHand.ResetAttachedTransform(player.rightHand.currentAttachedObjectInfo.Value); } } else { teleportingToMarker.TeleportPlayer(pointedAtPosition); } Teleport.Player.Send(pointedAtTeleportMarker); }