so when i try to change fov with script i get some null error, here’s the script:
var mainCam : Camera;
var normalPos : Vector3;
var aimPos : Vector3;
var weapon : GameObject;
function Start()
{
mainCam = Camera.main;
}
function Update()
{
if(Input.GetButton("Fire2"))
{
weapon.transform.localPosition = Vector3.Lerp(weapon.transform.localPosition, aimPos, Time.deltaTime * 8);
mainCam.fieldOfView = Mathf.Lerp(mainCam.fieldOfView, 45, Time.deltaTime * 10);
}
else
{
weapon.transform.localPosition = Vector3.Lerp(weapon.transform.localPosition, normalPos, Time.deltaTime * 8);
mainCam.fieldOfView = Mathf.Lerp(mainCam.fieldOfView, 60, Time.deltaTime * 10);
}
}