Question by
Tortoise41 · Aug 28, 2020 at 06:12 PM ·
triggertimetimertriggers
I need my timer to only start after it hits a trigger. Please help!
I have a timer and i need it to start after it hits the trigger.
public Text timerText; private float startTime; private bool finished = false;
// Start is called before the first frame update
void Start()
{
startTime = Time.time;
}
// Update is called once per frame
void Update()
{
if (finished)
return;
float t = Time.time - startTime;
string minutes = ((int)t / 60).ToString();
string seconds = (t % 60).ToString("f2");
timerText.text = minutes + ":" + seconds;
}
public void Finish()
{
finished = true;
timerText.color = Color.yellow;
}
Comment
Your answer
Follow this Question
Related Questions
Trigger a Timer 2 Answers
Box Coillider changes to trigger depending on speed of the object. 0 Answers
Level Unlock Help 0 Answers
OnTriggerEnter not working 2 Answers
How to create a timer that only increases when if command is true? 1 Answer