3DTD/Assets/Scripts/Camera/TowerCam.cs

36 lines
1.1 KiB
C#
Raw Normal View History

2024-04-21 02:09:30 +02:00
using Cinemachine;
using UnityEngine;
public class TowerCam : MonoBehaviour
{
2024-04-21 04:00:56 +02:00
[SerializeField] private GameObject m_gameObject;
public GameObject newTarget;
2024-04-21 02:09:30 +02:00
private void Start()
{
if (m_gameObject == null)
m_gameObject = this.gameObject;
}
public void ChangeToTarget(GameObject target)
{
if (target != null)
{
2024-04-21 04:00:56 +02:00
newTarget = target;
2024-04-21 02:09:30 +02:00
m_gameObject.GetComponent<CinemachineFreeLook>().m_LookAt = target.transform;
m_gameObject.GetComponent<CinemachineFreeLook>().m_Follow = target.transform;
m_gameObject.GetComponent<CinemachineFreeLook>().m_Priority = 11;
2024-04-21 03:22:56 +02:00
2024-04-21 04:00:56 +02:00
m_gameObject.GetComponent<CinemachineFreeLook>().GetRig(0).LookAt = target.transform;
m_gameObject.GetComponent<CinemachineFreeLook>().GetRig(1).LookAt = target.transform;
m_gameObject.GetComponent<CinemachineFreeLook>().GetRig(2).LookAt = target.transform;
2024-04-21 02:09:30 +02:00
}
else
{
m_gameObject.GetComponent<CinemachineFreeLook>().m_Priority = 9;
}
}
}