Hi,
At the start of each level, I want camera to wait 1 second and then zoom into the normal Field of View. I set my starting camera field of view to be zoomed out. This is the code I have:
#pragma strict
var zoomIn : float = 46;
var zoomOut : float = 65;
var smooth : float = 5;
function Start () {
yield WaitForSeconds (1);
Zoom();
}
function Zoom()
{
if(camera.fieldOfView > 46)
{
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, zoomIn, Time.deltaTime * smooth);
}
}
When I start the game, it waits for a second, and then jumps to a field of view just below the starting field of view. I’m guessing that’s because the Mathf.Lerp is only getting called one time, and is therefore interpolating one time. When I put the line of code that is in Zoom() in an Update function it works, but then it doesn’t wait before it zooms…
How can I make the camera wait before it zooms in?
for extremely simple timers in Unity, just use Invoke() eg Invoke( "zoomTheCamera", 1.5 );
– Fattie