using Cinemachine; using System.Collections; using System.Collections.Generic; using UnityEngine; public class LensOscillate : MonoBehaviour { public CinemachineVirtualCamera m_VirtualCamera; public float m_Speed; [SerializeField] private float m_FOV; private float m_SineValue = 0; private float m_Time; // Update is called once per frame void Update() { m_Time += Time.fixedDeltaTime; m_SineValue = Mathf.Sin(m_Time * m_Speed); m_FOV = Map(m_SineValue, -1, 1, 0.2f, 0.45f); m_VirtualCamera.m_Lens.OrthographicSize = m_FOV; } private float Map(float x, float x1, float x2, float y1, float y2) { var m = (y2 - y1) / (x2 - x1); var c = y1 - m * x1; // point of interest: c is also equal to y2 - m * x2, though float math might lead to slightly different results. return m * x + c; } }