Confused about DT

Get help using Construct 2

Post » Mon Jun 03, 2013 8:11 am

Hey you,

I have been looking the forums and tutorials but I haven't found anything that applies to me, just yet. Or maybe I don't fully understand. Anyways, I have a scrolling back that moves +6 pixels every tick.

I would like to do the same but with deltaTime. There doesn't seem to be an event for it. Any help?

Thank you,
Stephen
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Mon Jun 03, 2013 9:15 am

Deltatime is a constant... just reference it in your event by using Background.x=Background.x+6*dt (experiment here...)
B
33
S
6
G
7
Posts: 339
Reputation: 7,426

Post » Mon Jun 03, 2013 10:02 am

[QUOTE=Ize] Deltatime is a constant... just reference it in your event by using Background.x=Background.x+6*dt (experiment here...)[/QUOTE]

Actually delta-time is not constant, it is time that has been elapsed since last tick occurred. That can vary. :)

When using delta-time, you really can't say 'move 6 pixels forward every tick' as you are just going against the whole principle of the thing. Instead, you can say that 'move 6 pixels in time frame of one second'.

DT creates framerate independence. Regardless of what FPS player has, the object will move those 6 pixels in time frame of one second if you are using dt. If you are not using it, player with lower FPS would move LESS than player with higher FPS, as he will have less ticks in a second.vee412013-06-03 10:02:37
B
24
S
9
G
7
Posts: 756
Reputation: 7,302

Post » Mon Jun 03, 2013 1:07 pm

The tutorial delta-time and framerate independence covers exactly this.

Normally games run at 60 FPS. So if you move 6 pixels per tick, it's moving 6 x 60 = 360 pixels per second. However it will change if the framerate changes.

So to prevent it changing when the framerate changes, move it 360 * dt pixels per tick instead. Then it moves exactly the same speed as it did before at 60 FPS, but the actual speed does not change if the framerate changes.
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,684

Post » Mon Jun 03, 2013 5:33 pm

So, this is what I came up with @Ashley, @vee41, @Ize. I don't see a difference but I think that is mostly because I have a constant 60fps. I tried spawning 1000 objects and making them fly around but still no drop in fps. I will have to compile a mobile version and test it on my phone. Seeing as wifi preview doesn't work since I switched routers.

Anyways, here is what my events look like now. Is this correct?

Tekniko2013-06-03 17:34:16
B
56
S
15
G
13
Posts: 826
Reputation: 17,645


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], eochranek, Unconnected and 19 guests