hi,
how to make a timer in the racing game,(i mean 3,2,1. GO!)
THANK YOU…
using UnityEngine;
using System.Collections;
public class Timer : MonoBehaviour
{
float currentTime = 0;
int countValue = 3;
bool gameStarted = false;
void Start()
{
currentTime = Time.time;
}
void Update()
{
if (!gameStarted)
{
if (Time.time - currentTime >= 1)
{
Debug.Log(countValue);
countValue--;
currentTime = Time.time;
}
if (countValue == -1)
{
gameStarted = true;
StartGame();
}
}
}
void StartGame()
{
Debug.Log("Game is started");
}
}
U can use GUI Text go to Game Object → Create Other → GUI Text
and apply this script
var TextTop : GUIText; // assign GUI Text
function ShowText()
{
TextTop.text = "3";
yield WaitForSeconds(1);
TextTop.text = "2";
yield WaitForSeconds(1);
TextTop.text = "1";
yield WaitForSeconds(1);
TextTop.text = "Go....";
}