Hello
I would like to know why the scripts I’m using are not working properly with my timer i would really appreciate any help !
using System;
using System.Collections.Generic;
using UnityEngine;
public class Timertext : MonoBehaviour
{
public float timeLeft;
public GUIText Timer;
public GUIText gameOverText;
public void Update()
{
timeLeft -= Time.deltaTime;
if (timeLeft <= 0.0f) {
Timer.text = "You ran out of time";
gameOverText.text = "GAME OVER";
}
else
{
Timer.text = "Time left = " + (int)timeLeft + " seconds";
}
}
}
using UnityEngine;
using System.Collections;
public class Tanktimer : MonoBehaviour {
public Timertext Timertext;
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == "PickUp")
{
//add time
//Destroy(other.gameObject);
Timertext.timeLeft += 10;
}
}
}