In a game I've been working on, I required timing accuracy to approx. 1/10th of a second. I tried to use dt for this, but events wouldn't properly initiate via a dt tracking global/local variable, so I was forced to continue using regular "time", the kind you get when you use a condition of "system -> time = x seconds".
I would really appreciate any helping in determining a means of manipulating this form of time in C2. I would love to be able to reset it, freeze it, and change it's value.
I've spoken of this before, but dt was the only alternative at the time, and it plainly doesn't work for my project due to an unknown cause of imprecision. And yes, I know that 1/10th of a second doesn't conform with the framerate of most games, but the "time" variable still manages to respond to tenths of a second just fine, whereas dt does not.
So, is there any way to manipulate the "time"? If there isn't, I would really appreciate this feature being added if possible.
Don't think that's going to happen.
Then definitely not on mobiles.
Not with that kind of precision.
I'm not looking for precision, for some reason the "time" is precise enough, or at least acts as though it is. I just need a way to tell the "time" to reset, stop, or change values. I can't use dt for this.
Thanks for your responses!
Well dt has nothing to do with time. It's the time since the last frame, and that's it.
What you should do is use a variable, that you can control, as your measure of time. Basically set the variable to the system time.
But the problem is not all browsers are that accurate at keeping time.
Most mobiles are absolutely terrible at it.
Hmm, I know this sounds stupid, but I don't recall if I tried setting a variable to system time...I think I may have though...I'll test it out when I get some extra time. Thanks newt.
I still wouldn't mind the ability to control the time variable, though. :)
Are you trying to do a timer that does something after a tenth of a second? Like newt said use a variable and add dt to it every tick.
Say you call your variable "timer"; don't do a condition like this to see when a tenth of a second has passed.
timer = 0.1
"timer" will almost never be exactly 0.1, instead use ">=".
timer >= 0.1
and add a "trigger once" condition after it.
Develop games in your browser. Powerful, performant & highly capable.
The system time is also based on dt, so using dt in a variable should be about as good as comparing the system time. Like R0J0hound pointed out, a common mistake is to compare for an exact time, which is almost never triggered because time jumps in ~16ms steps with a lot of random variation. The system 'time equals...' condition automatically works around this, but for your own events you'll need to handle it yourself. The best way to handle it is something like: time greater than 0.1, trigger once.
Thanks Ashley and R0J0hound, I'll give that a go again! I do feel as though I recall it not working for me even under those conditions, but I could be mistaken.
I appreciate the help guys!