I found a C# Script that allows me to change the FOV of the camera in-game, it works well in the editor but when I play it on my Android phone it doesn’t work anymore. Did anyone get the same problems? Thanks for the help!
here is the code
using UnityEngine;
using System.Collections;
public class CameraZoom : MonoBehaviour {
//
public Camera caml;
public float zoomSpeed = 20f;
public float minZoomFOV = 10f;
public float maxZoomFOV = 60f;
public bool zoomedIn = false; //boolean that determines whether we are in zoomed in state or not
void Update () {
if (Input.GetButtonDown (“Fire3”)) {//(Input.GetKeyDown(“z”))//This function toggles zoom capabilities with the Z key. If it’s zoomed in, it will zoom out
zoomedIn = !zoomedIn;
}
if (zoomedIn == true) {
caml.fieldOfView -= zoomSpeed/8;
//Camera.main.fieldOfView -= zoomSpeed/8;
if (caml.fieldOfView < minZoomFOV)
{
caml.fieldOfView = minZoomFOV;
}
}
else
{
caml.fieldOfView = maxZoomFOV;
}
}
public void ZoomIn()
{
caml.fieldOfView -= zoomSpeed/8;
if (caml.fieldOfView < minZoomFOV)
{
caml.fieldOfView = minZoomFOV;
}
}
}