When the object gets destroyed in my game, I want a touch to continue
function after a delay. This is what I tried.
this is the SceneManager
class which is attached to the Main Camera
public bool ttc;
public void NextLevel()
{
StartCoroutine(Delay());
}
IEnumerator Delay()
{
yield return new WaitForSeconds(2);
print("touch to continue");
ttc = true;}
My Object class:
void OnDestroy()
{
Camera.main.GetComponent<SceneManager>().NextLevel();
if (Camera.main.GetComponent<SceneManager>().ttc == true)
{
if (Input.GetKeyDown(KeyCode.V))
{
Application.LoadLevel("TheGame2");
}
}
}
I also tried this:
IEnumerator Delay()
{
yield return new WaitForSeconds(2);
print("touch to continue");
if (Input.GetKeyDown(KeyCode.V))
{
Application.LoadLevel("TheGame2");
}
}
side note: I will change the 'KeyCode.V' to a mouse button later