54 lines
1.4 KiB
C#
54 lines
1.4 KiB
C#
using Cinemachine;
|
|
using UnityEngine;
|
|
|
|
public class TowerCam : MonoBehaviour
|
|
{
|
|
public static TowerCam instance;
|
|
|
|
[SerializeField] private GameObject m_gameObject;
|
|
|
|
public float originalOffset;
|
|
|
|
private void Start()
|
|
{
|
|
if (m_gameObject == null)
|
|
m_gameObject = this.gameObject;
|
|
|
|
if (instance == null)
|
|
instance = this;
|
|
}
|
|
|
|
public void ChangeToTarget(GameObject target)
|
|
{
|
|
originalOffset = m_gameObject.GetComponent<CinemachineCameraOffset>().m_Offset.z;
|
|
|
|
if (target != null)
|
|
{
|
|
m_gameObject.GetComponent<CinemachineFreeLook>().m_LookAt = target.transform;
|
|
m_gameObject.GetComponent<CinemachineFreeLook>().m_Follow = target.transform;
|
|
m_gameObject.GetComponent<CinemachineFreeLook>().m_Priority = 11;
|
|
|
|
m_gameObject.GetComponent<CinemachineCameraOffset>().m_Offset.z = 0;
|
|
|
|
HideWall.instance.target = target;
|
|
}
|
|
else
|
|
{
|
|
m_gameObject.GetComponent<CinemachineFreeLook>().m_Priority = 9;
|
|
|
|
m_gameObject.GetComponent<CinemachineCameraOffset>().m_Offset.z = originalOffset;
|
|
|
|
HideWall.instance.target = null;
|
|
}
|
|
}
|
|
|
|
public void ChangeToMainCamera()
|
|
{
|
|
m_gameObject.GetComponent<CinemachineFreeLook>().m_Priority = 9;
|
|
|
|
m_gameObject.GetComponent<CinemachineCameraOffset>().m_Offset.z = originalOffset;
|
|
|
|
HideWall.instance.target = null;
|
|
}
|
|
}
|