mirror of
https://github.com/OMGeeky/GameDevGameJamV2.git
synced 2025-12-30 08:13:41 +01:00
Movement & Attaching etc.
also cleanup
This commit is contained in:
25
Assets/Scripts/CameraController.cs
Normal file
25
Assets/Scripts/CameraController.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user