dt Explained

0 favourites
  • 8 posts
  • 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,

  • 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.

    More info

  • 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.

  • 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.

  • 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,

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The official behaviours that involve movement already incorporate dt.

  • 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,

    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.

  • Thank you very much to all. Very clear responses.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)