mirror of
https://github.com/OMGeeky/GameDevGameJamV2.git
synced 2025-12-27 14:59:08 +01:00
25 lines
555 B
C#
25 lines
555 B
C#
using Cinemachine;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
public class CameraController : MonoBehaviour
|
|
{
|
|
[SerializeField] private Character root;
|
|
[SerializeField] private CinemachineVirtualCamera vCam;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if ( vCam == null )
|
|
vCam = GetComponent<CinemachineVirtualCamera>();
|
|
|
|
root.Spawned += RootOnSpawned;
|
|
}
|
|
|
|
private void RootOnSpawned( Character obj )
|
|
{
|
|
var objTransform = obj.transform;
|
|
vCam.Follow = objTransform;
|
|
vCam.LookAt = objTransform;
|
|
}
|
|
} |