diff --git a/Assets/Scripts/Portals/PortalCamera.cs b/Assets/Scripts/Portals/PortalCamera.cs index 8c5d7a2..4b23e50 100644 --- a/Assets/Scripts/Portals/PortalCamera.cs +++ b/Assets/Scripts/Portals/PortalCamera.cs @@ -49,8 +49,7 @@ public class PortalCamera : MonoBehaviour } } - // Update is called every frame - void Update() + void LateUpdate() { // Gets the offset of the player from the display portal Vector3 offset = m_DisplayPortal.PlayerOffset(); @@ -63,8 +62,6 @@ public class PortalCamera : MonoBehaviour float angle = Quaternion.Angle(m_DisplayPortal.transform.parent.rotation, m_CapturePortal.transform.parent.rotation); Quaternion rotDif = Quaternion.AngleAxis(angle, Vector3.up); Vector3 newCamDir = rotDif * CameraController.Instance().transform.forward; - //Vector3 d = new(m_CapturePortal.CamDif(), 0f, 0f); - //Vector3 d = new(0f, 0f, m_CapturePortal.CamDif()); Vector3 d = new(0f, m_CapturePortal.CamDif(), 0f); transform.parent.eulerAngles = Quaternion.LookRotation(newCamDir, Vector3.up).eulerAngles + m_Rot + d; } diff --git a/Assets/Scripts/Portals/PortalManager.cs b/Assets/Scripts/Portals/PortalManager.cs index d4ba54a..866ef0c 100644 --- a/Assets/Scripts/Portals/PortalManager.cs +++ b/Assets/Scripts/Portals/PortalManager.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using UnityEngine; public class PortalManager : MonoBehaviour @@ -27,8 +28,6 @@ public class PortalManager : MonoBehaviour public float CamDif() => m_CamDif; - static bool s_TeleportedThisFrame = false; - // Start is called before the first frame update void Start() { @@ -48,16 +47,9 @@ public class PortalManager : MonoBehaviour m_PortalCamera.InitCamera(m_Renderers, this, transform.parent.localEulerAngles * 2.0f); } - // Updates is called every frame - void Update() - { - // Updates the player position relative to the portal - m_PlayerPoint.position = CameraController.Instance().transform.position; - } - void LateUpdate() { - s_TeleportedThisFrame = true; + m_PlayerPoint.position = CameraController.Instance().transform.position; } // When something enters the portal @@ -70,7 +62,7 @@ public class PortalManager : MonoBehaviour Vector3 difference = PlayerMovement.Pos() - transform.position; // If this is true the player has crossed the portal - if (PlayerMovement.CanGoThroughPortals() && s_TeleportedThisFrame == true) + if (PlayerMovement.CanGoThroughPortals()) { // Rotates the player float rotDif = -Quaternion.Angle(transform.rotation, m_OtherManager.transform.rotation) + m_AngleDif;