hi guys, building a small text based game,
so this code is designed to take out “secondd” as an int from another code and display it as text counting down. eg. 13…12…11…1…0.
what is actually happening is that the value freezes at the initial sourced value eg. 13 and doesn decrease from there because of the updating.
Any solutions?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Timeleft : MonoBehaviour {
public GameObject Posone;
public Posone timers;
public float secondd = 0;
public UnityEngine.UI.Text timer;
public int minus;
public int occu;
// Use this for initialization
void Update ()
{ timers = GameObject.FindGameObjectWithTag("p1").GetComponent<Posone>();
occu = timers.psonefull;
if(occu == 1){
timers = GameObject.FindGameObjectWithTag("p1").GetComponent<Posone>();
secondd = timers.ctp1;
secondd -= Time.deltaTime;
timer.text = "Time Left: " + secondd;
}
else{
timer.text = "Cure";
}
//Debug.Log(secondd);
}
}