Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using Cinemachine;
- /// <summary>
- /// Helper class for a Cinemachine virtual camera
- /// </summary>
- public class CamDriver
- {
- private CinemachineVirtualCamera vcam;
- private CinemachineFollowZoom followZoom;
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="camObj"></param>
- public CamDriver(GameObject camObj)
- {
- InitializeFromGameObject(camObj);
- }
- private void InitializeFromGameObject(GameObject camObj)
- {
- if (camObj != null) {
- vcam = camObj.GetComponent<CinemachineVirtualCamera>();
- followZoom= camObj.GetComponent<CinemachineFollowZoom>();
- }
- }
- public void SetTarget(Transform trackNode)
- {
- vcam.Follow = trackNode;
- vcam.LookAt = trackNode;
- }
- public void ZoomTo(float destSize, float duration = 0)
- {
- followZoom.m_Damping = duration;
- followZoom.m_Width = destSize;
- }
- public void Shake(float amount, float duration)
- {
- // TODO
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement