Hi, everything ive found has been for JS. how do you change field of view (Camera) inn C# over a set time?
using UnityEngine;
using System.Collections;
public class FoV : MonoBehaviour {
private IEnumerator coChangeFoV;
void Start() {
ChangeFoV(5, 10);
}
public void ChangeFoV (float duration, float value) {
if (coChangeFoV != null) {
StopCoroutine(coChangeFoV);
}
coChangeFoV = CoChangeFoV(duration, value);
StartCoroutine(coChangeFoV);
}
IEnumerator CoChangeFoV(float duration, float value) {
float t = 0.0f;
float startFoV = Camera.main.fieldOfView;
while (t != duration) {
t += Time.deltaTime;
if (t > duration) t = duration;
Camera.main.fieldOfView = Mathf.Lerp(startFoV, value, t / duration);
yield return null;
}
}
}
Call the function ChangeFoV() with parameters as you want, just like I did in Start();