public void LevelLocalTransformChanging(Vector3 old, Vector3 updated) { if (warper != null) { warper.SetWorldPosition(warper.transform.position + (updated - old) + Camera.main.transform.localPosition); } }
private void InitializeLocalPlayer() { if (isLocalPlayer) { Debug.Log("Setting instance for local player "); _Instance = this; Debug.LogFormat("Set local player name {0} ip {1}", networkDiscovery.broadcastData, networkDiscovery.LocalIp); CmdSetPlayerName(networkDiscovery.broadcastData); CmdSetPlayerIp(networkDiscovery.LocalIp); bool opaqueDisplay = UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque; Debug.LogFormat("local player {0} share anchors ", (opaqueDisplay ? "does not" : "does")); CmdSetCanShareAnchors(!opaqueDisplay); if (opaqueDisplay && levelState != null && levelState.isActiveAndEnabled) { Debug.Log("Requesting immersive path"); WaitingForFreePath = true; CmdRequestPathIndex(); } else { Debug.Log("Defaulting to bird's eye view"); CmdSendPathIndex(-1); if (opaqueDisplay && fadeManager != null && fadeManager.Busy == false) { fadeManager.DoFade(0.5f, 0.5f, () => { MixedRealityTeleport warper = MixedRealityTeleport.Instance; if (warper != null) { //warper.ResetRotation(); warper.SetWorldPosition(levelState.transform.position + levelState.transform.forward * -2.5f + Vector3.up * 0.25f + levelState.transform.transform.right * Random.Range(-2f, 2.0f)); } }, null); } } if (!opaqueDisplay && anchorManager.AnchorOwnerIP == "") { Invoke("DeferredAnchorOwnerCheck", 2.0f); } if (UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque) { InteractionManager.InteractionSourceUpdated += InteractionManager_InteractionSourceUpdated; } } }
void PathIndexChanged(int update) { Debug.LogFormat("{0}: Path index updated {1} => {2}", PlayerName, PathIndex, update); PathIndex = update; if (isLocalPlayer) { levelState.SetPathIndex(PathIndex); if (PathIndex == -1 && UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque) { Debug.Log("Getting in line"); WaitingForFreePath = true; if (fadeManager != null && fadeManager.Busy == false) { fadeManager.DoFade(0.5f, 0.5f, () => { MixedRealityTeleport warper = MixedRealityTeleport.Instance; if (warper != null) { // warper.ResetRotation(); warper.SetWorldPosition(levelState.transform.position + levelState.transform.forward * -2.5f + Vector3.up * 0.25f + levelState.transform.transform.right * Random.Range(-2f, 2.0f)); } }, null); } } else { WaitingForFreePath = false; } } else { levelState.OnPathMessage(PathIndex, PlayerName); } }
// Update is called once per frame void Update() { if (warping) { if (Input.GetButtonUp("Jump")) { warping = false; if (warpCancelled == false) { Vector3 hitPos = ActiveMarker.transform.position + Vector3.up * 2.6f; Vector3 goal = hitPos; fadeControl.DoFade(0.25f, 0.5f, () => { warper.SetWorldPosition(goal); Debug.DrawLine(hitPos, goal); }, null); } warpCancelled = false; DisableMarker(); } else { PositionMarker(); } } else { if (fadeControl.Busy == false && Input.GetButtonDown("Jump")) { warping = true; EnableMarker(); PositionMarker(); } } }