Hi,
I’m trying to swap cameras for the duration of the animation on CameraTwo.
And then return control to the First Person Controller. I tried creating a Coroutine to make a WaitForSeconds for the length of the animation.
The results are buggy.
Any code advise would be great.
public class CameraSwap : MonoBehaviour
{
public GameObject AirPlane;
public GameObject FirstPersonController;
public GameObject CameraTwo;
// Use this for initialization
void Start()
{
}
//Update is called once per frame
void Update()
{
if (AirPlane == null)
{
FirstPersonController.SetActive(false);
CameraTwo.SetActive(true);
CameraTwo.GetComponent<Animation>().Play("CameraZooom");
StartCoroutine("Wait");
}
}
IEnumerator Wait()
{
yield return new WaitForSeconds(5);
CameraTwo.SetActive(false);
FirstPersonController.SetActive(true);
}
}
}