Every dt vs Every tic !!

Discussion and feedback on Construct 2

Post » Sun Oct 12, 2014 11:48 pm

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
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Mon Oct 13, 2014 12:25 am

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.
Last edited by TiAm on Mon Oct 13, 2014 6:17 pm, edited 1 time in total.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Mon Oct 13, 2014 3:35 pm

Thank's for the help.
I'm using the both right now and i will do some tests to see where they fit.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Mon Oct 13, 2014 3:42 pm

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.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Mon Oct 13, 2014 4:01 pm

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?".
Image ImageImage
B
169
S
50
G
169
Posts: 8,287
Reputation: 108,218

Post » Mon Oct 13, 2014 6:16 pm

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.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Mon Oct 13, 2014 6:41 pm

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:
Code: Select all
global endTime=0

endtime >= time
--- Set endtime to time+dt
--- do stuff

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.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Oct 13, 2014 7:12 pm

R0J0hound wrote: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:
Code: Select all
global endTime=0

endtime >= time
--- Set endtime to time+dt
--- do stuff

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.
Don't lose your work. Backup your game with Dropbox.
B
44
S
10
G
10
Posts: 1,106
Reputation: 9,202

Post » Mon Oct 13, 2014 8:05 pm

You could do this to do something exactly 10 times per second.
Code: Select all
global elapsed_time=0

every tick
--- add dt to elapsed_time

repeat int(elapsed_time*10)
--- subtract 1/10 from elapsed_time
--- do something


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.
https://dl.dropboxusercontent.com/u/542 ... erval.capx

Edit:
This could have a downward spiral effect if the framerate takes a bad it because this will make it worse.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Tue Oct 14, 2014 6:56 pm

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.
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Next

Return to Construct 2 General

Who is online

Users browsing this forum: higher2003 and 20 guests