iT DONTY WORK KDJMGHDFSJHFG

This commit is contained in:
Pasha Bibko
2025-04-02 07:55:08 +01:00
parent 70a71a06e5
commit 140cbd646f
5 changed files with 297 additions and 21 deletions

View File

@@ -8,7 +8,7 @@ public class PortalCamera : MonoBehaviour
// Private members //
PortalManager m_DisplayPortal;
public PortalManager m_DisplayPortal;
PortalManager m_CapturePortal;
RenderTexture m_RenderTexture;
@@ -43,8 +43,9 @@ public class PortalCamera : MonoBehaviour
// Update is called every frame
void Update()
{
// Calculates the player distance from where the portal will be rendererd
Vector3 offset = CameraController.Instance().transform.position - m_DisplayPortal.pos;
transform.parent.position = m_CapturePortal.TranslateOffset(offset);
Vector3 offset = m_CapturePortal.PlayerOffset();
transform.parent.position = offset;
transform.parent.position = m_CapturePortal.TranslateOffsetToSpace(m_DisplayPortal.PlayerOffset(), Vector3.zero);
}
}

View File

@@ -1,4 +1,3 @@
using System.ComponentModel;
using UnityEngine;
public class PortalManager : MonoBehaviour
@@ -9,7 +8,11 @@ public class PortalManager : MonoBehaviour
[Header("Set References")]
[SerializeField] GameObject m_CameraPrefab;
[SerializeField] MeshRenderer m_PortalRenderer;
[SerializeField] Transform m_CapturePoint;
[Header("Points")]
[SerializeField] Transform m_PlayerPoint;
[SerializeField] Transform m_Pos;
[SerializeField] Transform m_Rot;
PortalManager m_OtherManager;
PortalCamera m_PortalCamera;
@@ -19,6 +22,10 @@ public class PortalManager : MonoBehaviour
public Vector3 pos => transform.parent.position;
public Quaternion rot => transform.parent.rotation;
public void SetPos(Vector3 v) => transform.parent.position = v;
public Vector3 PlayerOffset() => m_PlayerPoint.position;
// Start is called before the first frame update
void Start()
{
@@ -37,9 +44,18 @@ public class PortalManager : MonoBehaviour
// Initialises the camera so it renders to the portal and not the screen
m_PortalCamera.InitCamera(m_PortalRenderer, this);
}
public Vector3 TranslateOffset(Vector3 offset)
// Updates is called every frame
void Update()
{
m_CapturePoint.localPosition = offset;
return m_CapturePoint.position;
m_PlayerPoint.position = CameraController.Instance().transform.position;
}
public Vector3 TranslateOffsetToSpace(Vector3 pos, Vector3 euler)
{
m_Rot.localEulerAngles = euler;
m_Pos.localPosition = pos;
return m_Pos.position;
}
}