unity timer with an int code example
Example 1: unity timer
float timeLeft = 30.0f;
void Update()
{
timeLeft -= Time.deltaTime;
if(timeLeft < 0)
{
GameOver();
}
}
Example 2: unity interval timer
public Rigidbody projectile;
void Start(){
//(methodname, timeUntilFirstCall, repeatTime)
InvokeRepeating("LaunchProjectile", 2.0f, 0.3f); //time needs to be > 0
}
void LaunchProjectile(){
Rigidbody instance = Instantiate(projectile);
instance.velocity = Random.insideUnitSphere * 5;
}