Codes first:
Variables:` public float timer; public string CurrentTime; public string DT; `
DT = "2013-10-25T15:35:15.858000"; //DT is a string that i read from a JSON
In Update(), check if my timer reaches DT:` void Update() { timer+=Time.deltaTime*500; Timer(); if (DT!=""){ if (CurrentTime == DT.Substring(11,8)){ trigger = true; } } } `
Timer function:` void Timer(){ int hours = Mathf.FloorToInt(timer / 3600F); int minutes = Mathf.FloorToInt((timer- hours *3600) / 60F); int seconds = Mathf.FloorToInt(timer - hours * 3600 - minutes* 60); CurrentTime = string.Format("{0:00}:{1:00}:{2:00}", hours,minutes,seconds); //Debug.Log(CurrentTime); } `
As you can see, i am trying to do something when my timer reaches the time i read from database. I want to increase the timer speed so it won’t take forever to trigger. I tried to increase it 500 times faster but the “if” checking is never true. I suspect that the timer is speed up by a step of 500, not really 500 times faster with every count. How can i make it 500 times faster without missing count? Any help would be appriciated. Thanks!