2025-05-23 20:37:10 +05:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class CameraController : MonoBehaviour
|
|
|
|
|
{
|
2025-05-27 17:01:22 +05:00
|
|
|
|
public Camera cam;
|
|
|
|
|
public float targetFOV = 30f;
|
2025-05-23 20:37:10 +05:00
|
|
|
|
public float zoomSpeed = 2f;
|
2025-05-27 17:01:22 +05:00
|
|
|
|
private bool zooming = false;
|
2025-05-23 20:37:10 +05:00
|
|
|
|
|
2025-05-27 17:01:22 +05:00
|
|
|
|
public void StartZoom()
|
2025-05-23 20:37:10 +05:00
|
|
|
|
{
|
2025-05-27 17:01:22 +05:00
|
|
|
|
zooming = true;
|
2025-05-23 20:37:10 +05:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-27 17:01:22 +05:00
|
|
|
|
void Update()
|
2025-05-23 20:37:10 +05:00
|
|
|
|
{
|
2025-05-27 17:01:22 +05:00
|
|
|
|
if (zooming)
|
2025-05-23 20:37:10 +05:00
|
|
|
|
{
|
2025-05-27 17:01:22 +05:00
|
|
|
|
cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, targetFOV, Time.deltaTime * zoomSpeed);
|
2025-05-23 20:37:10 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|