I’ve only been using Unity for a few days (for class) and I’m trying to create a scene to simulate being drunk. One of the things I’m trying to implement to do this is a script on the main camera that will smoothly slide the Field of View back and forth between 60 and 120 degrees. I’m having little success so far, as my current script only ticks back and forth between 58 degrees and 60 degrees. Can anyone set me on the right path?
My script:
using UnityEngine;
using System.Collections;
public class FOValter : MonoBehaviour
{
public float currentFOV = 90f;
public float rateOfChange = 0.1f;
public float ticker = 0;
void Update()
{
if (ticker == 30)
{
if (currentFOV > 118 || currentFOV < 62)
{
rateOfChange *= -1;
}
currentFOV += rateOfChange;
Camera.main.fieldOfView = currentFOV;
ticker = 0;
}
ticker++;
}
}