0 Favourites

Every dt vs Every tic !!

  • Hello all

    I'm confused should i use Every tic Or Every dt time On my events.

    Because i noticed that using dt better than using tic.

    For example i have a rope player can climb, When i add dt to the event and test the game on Low fps pc the climb go smoothly, And when i delete the dt The climb go very slow.

    Any help will be great.

    Thank's

  • Every tick does not scale as the framerate gets lower. So, if your framerate is 10fps, an every tick action will seem to take place at 1/6th the proper speed.

    On the other hand, dt scales to lower framerates. Thus, actions will appear to happen at the same speed, though dt controlled animations may look very choppy.

    Generally, dt is preferable. However, for some games (for example, puzzle games) it is preferable to handle things with per tick logic, as the timescaling effects of dt can cause glitchs such as collisions not registering.

  • Thank's for the help.

    I'm using the both right now and i will do some tests to see where they fit.

  • Both should be equivalent, as every tick is basically every dt (ticks are separated by dt), however I would think that every dt is actually one tick behind for the measure, thus the difference.

    Unless I am mistaking due to how you describe it, as it seems that it result with a framerate independency (which is normally done using *dt to the variations), anyway, every dt seconds should not be different I think, if it is, you should show us the exact events used.

  • Dt is only useful when you expect fps to change.

    Or more aptly, when a fps change would interfere with gameplay, movement being the biggest example.

    A good rule of thumb would be "what do you expect to happen when dt is 0?".

  • Whoops, bit of a brain glitch there...I was thinking of *dt applications, or using 'Every X seconds'. I guess if you literally went 'Do X every dt', it would function identically to 'Do X every tick'.

    Actually...that brings an idea to mind. If you were making a framerate dependant game, and you wanted an action to repeat every few ticks (say every 3, or 4), you could approximate that without using a timer by going:

    Every dt*(TickInterval) seconds.

  • My guess is "every dt seconds" will in practice will have the possibility of running less than a "every tick" event.

    As I understand it the "every dt seconds" event could be done like this:

    global endTime=0
    
    endtime >= time
    --- Set endtime to time+dt
    --- do stuff
    [/code:1u5sb0c0]
    So if it ran on a slow frame it could not run on the next frame if it was a fast frame.  Although it could still be acceptable, unless absolute precision is needed.
  • My guess is "every dt seconds" will in practice will have the possibility of running less than a "every tick" event.

    As I understand it the "every dt seconds" event could be done like this:

    > global endTime=0
    
    endtime >= time
    --- Set endtime to time+dt
    --- do stuff
    [/code:3w07yjcm]
    So if it ran on a slow frame it could not run on the next frame if it was a fast frame.  Although it could still be acceptable, unless absolute precision is needed.
    

    That's true. I suppose you could get a little closer by averaging the last 2 or 3 dt values and using that value instead.

  • You could do this to do something exactly 10 times per second.

    global elapsed_time=0
    
    every tick
    --- add dt to elapsed_time
    
    repeat int(elapsed_time*10)
    --- subtract 1/10 from elapsed_time
    --- do something[/code:2niyz02n]
    
    You can extend than to take into account time.  So for instance you can have a constant stream of evenly spaced bullets at say 10 per second.
     [url=https://dl.dropboxusercontent.com/u/5426011/examples25/bullet_exact_interval.capx]https://dl.dropboxusercontent.com/u/542 ... erval.capx[/url]
    
    Edit:
    This could have a downward spiral effect if the framerate takes a bad it because this will make it worse.
  • Thanks alot for the help, I'm asking this because i want to publish my game online and i want to make sure every thing will be ok even when run in low fps.

    I will test the capx when i get back to home.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • If you mean using 'dt' in the 'Every X seconds' condition, that is incorrect - don't do it!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
87 5,378
facecjf's avatar
facecjf
Unread hot topic
65 15,840
philx's avatar
philx
Unread hot topic
42 5,111
Jayjay's avatar
Jayjay