# dt Explained

Get help using Construct 2

### » Mon Oct 21, 2013 4:51 pm

Hi everyone,

Could someone explain me with easy and practical examples what "dt" is used for? For example, a situation when dt is used vs one where it is not used.

I have seen it is sometimes used as multiplier for movement functions to "normalize" movement, but i have not being able to understand the concept. Does this mean dt should always be used as a multiplier when dealing with movement? In which cases should it be used?

Kind regards,
B
6
S
2
Posts: 30
Reputation: 1,127

### » Mon Oct 21, 2013 5:16 pm

dt or delta-time is the amount of time that has passed since the game last updated. It is used to make sure that any calculations that have it in there are framerate independent. A time that you would use dt is if you are gradually moving an object in a direction (eg. a bullet). A time you wouldn't want to use dt is if you are moving an object to the right x distance on each click. If you used dt, it would multiply the 100 pixels you wanted to move the object by a very small number, which in turn would hardly move it.

B
48
S
15
G
8
Posts: 603
Reputation: 8,766

### » Mon Oct 21, 2013 5:18 pm

Typing *dt really means "per second" for all practical and non-ridiculous intents. It is a way to make sure the game moves at just about the same rate regardless of performance. For instance, in a non-dt setting, typing Every tick: set X to object.x+5, it will add 5 to the object's x position every tick. Unfortunately, the rate of ticks between computers can vary quite a bit.

So we would use dt instead. Every tick: set X to object.X+100*dt so it will move 100 pixels per second regardless of framerate (in nearly all cases). It works for all number values, so you can do the same thing with opacity, scale, scores, etc. And, since you now have a global value incorporated, you can change the rate of movement for everything (think slow-mo) by just changing the dt value at runtime in the system expressions. But the most common use is for smooth and consistent movement across different computers/platforms.

Edit - Ah Cow ninja'd me.C-72013-10-21 17:19:23
B
104
S
38
G
19
Posts: 962
Reputation: 18,026

### » Mon Oct 21, 2013 5:28 pm

Yeah - a good rule of thumb is any time you'd use 'per second', you'd use dt. keep in mind some system expressions/conditions/actions already incorporate dt, e.g. timers, every X seconds, etc.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,739

### » Mon Oct 21, 2013 7:58 pm

Thank you very much. very good explanation. But i still have a doubt. When i appply physics behaviour movement do i still have to use dt or is it already incorporated? For example, when i apply an impulse or force to an object, which makes it move, should i mutyply the force x dt?

Kind regards,
B
6
S
2
Posts: 30
Reputation: 1,127

### » Mon Oct 21, 2013 9:01 pm

The official behaviours that involve movement already incorporate dt.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

### » Tue Oct 22, 2013 2:20 am

[QUOTE=PressStart] Thank you very much. very good explanation. But i still have a doubt. When i appply physics behaviour movement do i still have to use dt or is it already incorporated? For example, when i apply an impulse or force to an object, which makes it move, should i mutyply the force x dt?

Kind regards,[/QUOTE]

Anything that would be a single-shot or one-off, you would not use dt. You would only use it if you are constantly or gradually changing values.
B
104
S
38
G
19
Posts: 962
Reputation: 18,026

### » Tue Oct 22, 2013 4:28 pm

Thank you very much to all. Very clear responses.
B
6
S
2
Posts: 30
Reputation: 1,127