Hello I really could use some help with this!
Ii have a script (which I will link below) That cross fades two cameras together but only if I press the space bar.
How will I be able to change it so instead of pressing space bar it changes every couple of seconds?
Here is the script:
using UnityEngine;
using System.Collections;
public class CrossFadeExample : MonoBehaviour
{
public Camera camera1;
public Camera camera2;
float fadeTime = 2.0f;
public AnimationCurve curve;
private bool inProgress = false;
private bool swap = false;
void Update ()
{
if (Input.GetKeyDown ("space")) {
DoFade ();
}
}
void DoFade ()
{
if (inProgress) {
return;
}
inProgress = true;
swap = !swap;
StartCoroutine (delayLine ());
}
IEnumerator delayLine ()
{
Camera tmpCam1;
Camera tmpCam2;
if (swap) {
tmpCam1 = camera1;
tmpCam2 = camera2;
} else {
tmpCam1 = camera2;
tmpCam2 = camera1;
}
print ("going to do something:");
StartCoroutine (ScreenWipe.use.CrossFade (tmpCam1, tmpCam2, fadeTime, curve));
yield return new WaitForSeconds (2.1f);
inProgress = false;
print ("done");
}
}
Any help is appreciated!