How can I add time to our timer when a target is destroyed? C#
What I'm trying to do in my game mode is have the player run around and find/shoot targets but most players can't do it within the given timeframe, so I was wondering how I could add time whenever one target is destroyed?
Here is my timer script:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Countdown : MonoBehaviour {
float timeLeft = 90.0f;
public Text text;
void Update()
{
timeLeft -= Time.deltaTime;
text.text = "Time Left: " + Mathf.Round(timeLeft);
if(timeLeft < 0)
{
Application.LoadLevel("Title");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Need to create a Time Trial in Unity with C# 1 Answer
Need help with making disappearing platforms. Error CS1525 1 Answer
HH:MM:SS game clock with modifiable start time error 1 Answer
Timer float not evaluating correctly when I check if it's less than another number 3 Answers
Timer only goes for .02 seconds 1 Answer