I am using the HDRP, so I decided to use the predefined sensor sizes to change the FOV when the player ADSs. I also don’t like it in games when you have to toggle the ADS so I’m not using that code, and I have it as a hold action.
private Camera camera;
[SerializeField] private Vector2 aimDownSightsSensorSize;
[SerializeField] private Vector2 normalSensorSize;
private void Start()
{
camera = GetComponentInChildren<Camera>();
}
private void Update()
{
ProcessAimDownSights();
}
void ProcessAimDownSights()
{
if (Input.GetMouseButton(1))
{
camera.sensorSize = aimDownSightsSensorSize;
}
else
{
camera.sensorSize = normalSensorSize;
}
}