3rd Level
This commit is contained in:
@@ -1,21 +1,40 @@
|
||||
using Cinemachine;
|
||||
using Level;
|
||||
using UnityEngine;
|
||||
using UnityEngine.U2D;
|
||||
|
||||
namespace Camera
|
||||
{
|
||||
public class CameraPlayerFinder : MonoBehaviour
|
||||
{
|
||||
private const float FollowOrthoSize = 7.5f;
|
||||
private const float FixedOrthoSize = 15f;
|
||||
private CinemachineVirtualCamera _cinemachineVirtualCamera;
|
||||
private PixelPerfectCamera pixelPerfectCamera = null;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_cinemachineVirtualCamera = GetComponent<CinemachineVirtualCamera>();
|
||||
pixelPerfectCamera = GameObject.FindObjectOfType<PixelPerfectCamera>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_cinemachineVirtualCamera.Follow == null && GameObject.FindWithTag("Player") != null && !GameObject.Find("Fixed Camera Point"))
|
||||
_cinemachineVirtualCamera.Follow = GameObject.FindWithTag("Player").transform;
|
||||
if (LevelManager.Instance.CurrentLevel?.FixedCameraPoint == null)
|
||||
{
|
||||
if (_cinemachineVirtualCamera.Follow == null)
|
||||
{
|
||||
_cinemachineVirtualCamera.Follow = LevelManager.Instance.Player.transform;
|
||||
_cinemachineVirtualCamera.m_Lens.OrthographicSize = FollowOrthoSize;
|
||||
pixelPerfectCamera.enabled = false;
|
||||
}
|
||||
}
|
||||
else if (_cinemachineVirtualCamera.Follow != LevelManager.Instance.CurrentLevel.FixedCameraPoint)
|
||||
{
|
||||
_cinemachineVirtualCamera.Follow = LevelManager.Instance.CurrentLevel.FixedCameraPoint;
|
||||
// _cinemachineVirtualCamera.m_Lens.OrthographicSize = FixedOrthoSize;
|
||||
pixelPerfectCamera.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user