I have a class file that zooms the camera for aiming. I also have a zoom animation for my gun. What i want to do is wait for the gun to catch up some before i do the camera zoom. It zooms by the right mouse button down event
However, it just doesnt seem to do anything like the function is not being called. I have looked at numerous examples and i dont see what i am doing wrong?
UPDATE: I got it fixed. I will revise my code to reflect that incase anyone else has problems down the road.
void Update () {
StartCoroutine("fieldOfView");
}
IEnumerator fieldOfView(){ // Not IEnumerable
if(Input.GetMouseButtonDown(1)){
aim = true;
ready = false;
}
if(Input.GetMouseButtonUp(1)){
aim = false;
}
if(aim){
yield return new WaitForSeconds(2);
cam.camera.fieldOfView = Mathf.Lerp(cam.camera.fieldOfView, distance, speed * Time.deltaTime);
}
if(!aim){
cam.camera.fieldOfView = Mathf.Lerp(cam.camera.fieldOfView, original_position, speed * Time.deltaTime);
}
}
Every example i have tried has not worked.