Actually stopping time (not dt)

Get help using Construct 2

Post » Mon Oct 22, 2012 12:05 am

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.

Thank you!teahousemoon2012-10-22 00:06:30
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Post » Mon Oct 22, 2012 12:17 am

Don't think that's going to happen.
Least not with javascript.
Then definitely not on mobiles. newt2012-10-22 00:17:29
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Oct 22, 2012 12:23 am

@newt

Javascript has an internal clock that can't be easily manipulated?
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Post » Mon Oct 22, 2012 12:26 am

Not with that kind of precision.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Oct 22, 2012 12:29 am

@newt

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!teahousemoon2012-10-22 00:29:51
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Post » Mon Oct 22, 2012 2:11 am

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.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Oct 22, 2012 3:06 am

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. :)
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Post » Mon Oct 22, 2012 5:58 am

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.
[code]timer = 0.1[/code]
"timer" will almost never be exactly 0.1, instead use ">=".
[code]timer >= 0.1[/code]
and add a "trigger once" condition after it.
R0J0hound2012-10-22 05:59:29
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Mon Oct 22, 2012 1:36 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Tue Oct 23, 2012 5:13 am

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!
B
28
S
6
G
5
Posts: 248
Reputation: 5,463

Next

Return to How do I....?

Who is online

Users browsing this forum: makkancs, Matthew de and 39 guests