What is delta time?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Ratty, Delta timing insures that your game runs at the same speed regardless of framerate.

    For example:

    A 60 FPS game with the following code:

    Always
    - Set X Position of "Object 1" to X Position of "Object 1" + 1

    Will move the object 60 pixels PER Second (60 fps / 1 pixels per frame = 60 pixels traveled")

    A 30 FPS game with the following code:

    Always
    - Set X Position of "Object 1" to X Position of "Object 1" + 1

    Will move the object 30 pixels PER Second (30 fps / 1 pixels per frame = 30 pixels traveled")

    If you use delta timing and you tell the object to move 60 pixels over the course of 1 second, it will move 60 pixels no matter the fps. Even at 5 fps, the object will move 60 pixels every 5 frames.


    You're trying to make a rhythm game? I recently found a great method of syncing notes to music for a DJMax Technika Simulator. It seems to work properly at any framerate using only the Built In Timer AND the current position of the audio you are playing. Do you have skype or any instant messengers? I'd be willing to go over some things with you if you're interested.

  • Delta is the difference (or change) between two values. In this case (to be specific) it's the value between two points in time; the timer data from last rendered frame and the timer data from current frame.

    In other engines the timer value may be extracted each main loop.


    If the developer has the capacity to store decimals it's easier to divide the delta of timer with 1000 since that results in "amount of seconds" since last frame.

    If the developer only has integer capacity; ie, the application use a native Fusion array to store/iterate movement. It's less work to use milliseconds.

    Please login to see this link.

  • Basically, it's a method of making events framerate independent, which helps to avoid synchronization issues.

    Lets say your game runs at 50 frames per second. That means a delay of 20 milliseconds between each frame.
    If you have an event that "Always" moves an object 5 pixels, it means that in 60 milliseconds, the event will run 60 / 20 = 3 times, and the object will move 5 x 3 = 15 pixels.

    But now, what if the computer is old and slow, and takes 30 milliseconds to handle each frame?
    Now in 60 milliseconds (of real time), the "Always" event only runs 60 / 30 = 2 times, so the object only moves 5 x 2 = 10 pixels. So you can see that if it's crucial for events to be perfectly synced to real time, this is going to be a problem.

    The solution is to use delta timing (in science, the Greek letter delta symbolizes change/difference), which works like this:
    Firstly, we measure the "delta time" - the amount of time that has elapsed in the real world since the last frame was processed.
    Next, instead of moving the object 5 pixels, we move it deltaTime * 0.25 pixels.

    Now, as before, if the game is running at 50FPS the delay between each frame (delta time) is 20 milliseconds. In 60 milliseconds, the event runs 60 / 20 = 3 times, and the object moves (20 * 0.25) * 3 = 15 pixels, which is the same as in our first example.
    But again, what if the delay between each frame (delta time) rises to 30 milliseconds?
    Now, the event runs 60 / 30 = 2 times, and the object moves (30 * 0.25) * 2 = 15 pixels, so this time, the object has still moved the same distance in the same amount of time, and everything is still nicely in sync.

  • I think delta-time and making everything unicode should be pinned somewhere. When I started developing I had no idea, but knowing these stuff would have been very useful. Just feels a huge part of the development so it would be amazing for the new users to find this info more easily. :)

    Currently working on Please login to see this link.
    Released games: Please login to see this link. and Please login to see this link.


  • You're trying to make a rhythm game? I recently found a great method of syncing notes to music for a DJMax Technika Simulator. It seems to work properly at any framerate using only the Built In Timer AND the current position of the audio you are playing. Do you have skype or any instant messengers? I'd be willing to go over some things with you if you're interested.

    GamesterX23, it would be greatly appreciated if you could upload an example and submit it over the Guides and Examples forum. I'm looking forward to it! :)

    <span style="font-weight: bold">My MMF2 Application:</span>
    Please login to see this link. - Windows XP Tweaking Tool
    Please login to see this link. - FLV/MP4 Player Example made by MMF2

  • Very thorough answers, everyone. Thanks for those! Seems Delta Time is the way to go for quite a few things in the future.

    And Gamester, I'd love to see what sort of notes you've drummed up!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!