User Tag List

Results 1 to 7 of 7

Thread: What is delta time?

  1. #1
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    What is delta time?

    Can someone explain what delta time is? I've seen in ther forums that it might be the lynch pin in finally creating a solid rhythm game. I'm curious.

  2. #2
    Clicker

    Fusion 2.5Android Export Module

    Join Date
    Jan 2007
    Posts
    281
    Mentioned
    8 Post(s)
    Tagged
    1 Thread(s)
    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.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    tompa's Avatar
    Join Date
    Nov 2011
    Location
    Uppsala, Sweden
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    Clicker

    Fusion 2.5 Developer
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    J3sseM's Avatar
    Join Date
    Feb 2013
    Location
    Finland
    Posts
    868
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    Clicker Fusion 2.5Fusion 2.5 MaciOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Apr 2008
    Location
    Indonesia
    Posts
    694
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by GamesterX23 View Post
    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!

  7. #7
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)Universal Windows Platform Export Module (Steam)
    ratty's Avatar
    Join Date
    Apr 2012
    Posts
    1,165
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    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!

Similar Threads

  1. Including delta-time in fast loop movement?
    By J3sseM in forum Fusion 2.5
    Replies: 12
    Last Post: 30th May 2015, 12:44 PM
  2. Adapting Movement to Delta-time
    By Chrille in forum Fusion 2.5
    Replies: 2
    Last Post: 22nd March 2015, 08:43 PM
  3. Replies: 3
    Last Post: 12th November 2014, 09:15 PM
  4. Delta Time acting wierd?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 22nd November 2013, 02:54 AM
  5. Correct way to calculate a delta time on MMF?
    By BHGames in forum iOS Export Module Version 2.0
    Replies: 5
    Last Post: 3rd July 2011, 03:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •