From a202fd5e6a841f9a07af84fe5112bde57e042571 Mon Sep 17 00:00:00 2001 From: Amaan Shawkath Date: Sun, 13 Jun 2021 03:28:35 +0100 Subject: [PATCH] potential fix for network camera --- Assets/Models/Main.unity | 9 +++++---- Assets/Scripts/GameManager.cs | 19 ++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Assets/Models/Main.unity b/Assets/Models/Main.unity index a0acbde..c375cbd 100644 --- a/Assets/Models/Main.unity +++ b/Assets/Models/Main.unity @@ -976,7 +976,7 @@ MonoBehaviour: ModeOverride: 0 LensShift: {x: 0, y: 0} GateFit: 2 - m_SensorSize: {x: 1.7091503, y: 1} + m_SensorSize: {x: 1.5816994, y: 1} m_Transitions: m_BlendHint: 0 m_InheritPosition: 0 @@ -1607,7 +1607,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 714303808} - m_LocalRotation: {x: -0.00849294, y: 0.30381006, z: -0.073214345, w: -0.9498774} + m_LocalRotation: {x: -0.008523712, y: 0.3021867, z: -0.072742335, w: -0.95043105} m_LocalPosition: {x: -0, y: 0.36, z: 2.5} m_LocalScale: {x: 4, y: 4, z: 4} m_Children: @@ -1644,7 +1644,7 @@ MonoBehaviour: ModeOverride: 0 LensShift: {x: 0, y: 0} GateFit: 2 - m_SensorSize: {x: 1.7091503, y: 1} + m_SensorSize: {x: 1.5816994, y: 1} m_Transitions: m_BlendHint: 0 m_InheritPosition: 0 @@ -3733,7 +3733,7 @@ MonoBehaviour: ModeOverride: 0 LensShift: {x: 0, y: 0} GateFit: 2 - m_SensorSize: {x: 1.7091503, y: 1} + m_SensorSize: {x: 1.5816994, y: 1} m_Transitions: m_BlendHint: 0 m_InheritPosition: 0 @@ -3774,6 +3774,7 @@ MonoBehaviour: player: {fileID: 750378831} activeCamera: {fileID: 381303739} networkCamera: {fileID: 561286952} + playerCamera: {fileID: 381303739} activeNode: {fileID: 0} previousNode: {fileID: 0} networkView: 0 diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index eab4a8f..ef01f01 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -10,10 +10,13 @@ public class GameManager : MonoBehaviour public GameObject player; public CinemachineVirtualCamera activeCamera; public CinemachineVirtualCamera networkCamera; + public CinemachineVirtualCamera playerCamera; public GameObject activeNode; public Node previousNode; public bool networkView = false; + private bool exiting = false; + // Start is called before the first frame update void Start() { @@ -21,13 +24,21 @@ public class GameManager : MonoBehaviour } public void SetActiveCamera(CinemachineVirtualCamera vCam) - { + { + if (vCam == networkCamera && activeCamera != networkCamera && activeCamera != playerCamera) + { + exiting = true; + } + else + { + exiting = false; + } + vCam.Priority = 20; activeCamera.Priority = 0; activeCamera = vCam; - if(!activeCamera == networkCamera) { networkView = false; } - + networkView = (!exiting && activeCamera == networkCamera) ? true : false; } // Update is called once per frame @@ -38,11 +49,9 @@ public class GameManager : MonoBehaviour private void FixedUpdate() { - //Leave network view with x if (Keyboard.current.xKey.wasPressedThisFrame && networkView) { - player.GetComponent().enabled = true; SetActiveCamera(networkCamera); activeNode.GetComponent().DisableNode(); activeNode = null;