Hello. I am making a game that is intended for the Android and is 2D. I can’t figure out how to load a level after 30 seconds. The game is supposed to last only 30 seconds and then is suppose to take you to a different scene ( Level ).
The script I am using is
using UnityEngine;
using System.Collections;
public class Clock : MonoBehaviour {
int hours;
public int hours24;
public float minutes;
public int iMinutes;
string fMinutes;
string ampm;
TextMesh clockText;
void Start () {
clockText = GetComponent<TextMesh> ();
hours = 12;
hours24 = 12;
minutes = 01;
ampm = "pm";
}
void Update () {
// Build Time. Default is one minute per second.
minutes += Time.deltaTime;
iMinutes = (int) minutes ;
fMinutes = iMinutes.ToString("D2");
if (iMinutes >= 60)
{
if (hours == 12)
{
hours = 0;
}
if (hours == 11)
{
if (ampm == "am")
ampm = "pm";
else
ampm = "am";
}
if (hours24 == 23)
hours24 = 0;
hours += 1;
hours24 += 1;
iMinutes = 0;
minutes = 0;
}
clockText.text = fMinutes ;
}
}
The counter works with Iminutes which are called minutes but count in seconds.
How can I modify the script that when the Iminutes reaches 30 a different scene loads.
All help is appreciated. If there are any questions, please ask.