You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HighGroundRoyaleNetcode/Assets/Scripts/CameraUtils/CameraController.cs

41 lines
1.1 KiB
C#

using Cinemachine;
using System;
using UnityEngine;
using UnityEngine.Assertions;
namespace Unity.BossRoom.CameraUtils
{
public class CameraController : MonoBehaviour
{
private CinemachineFreeLook m_MainCamera;
// Action to notify when the camera attaches (with character transform)
public static Action<Transform> OnCameraAttached;
void Start()
{
AttachCamera();
}
private void AttachCamera()
{
m_MainCamera = GameObject.FindObjectOfType<CinemachineFreeLook>();
Assert.IsNotNull(m_MainCamera, "CameraController.AttachCamera: Couldn't find gameplay freelook camera");
if (m_MainCamera)
{
// Camera follows and looks at this character
m_MainCamera.Follow = transform;
m_MainCamera.LookAt = transform;
// Default rotation / zoom
m_MainCamera.m_Heading.m_Bias = 40f;
m_MainCamera.m_YAxis.Value = 0.5f;
// Invoke Action to notify other scripts
OnCameraAttached?.Invoke(transform);
}
}
}
}