I had resubmitted this question with the correct required information. Consider
ID: 3762244 • Letter: I
Question
I had resubmitted this question with the correct required information.
Consider the sampling theory for the clock with three hands (i.e., the hour hand, the minute hand, and the second hand) If you were to record for a video shoot of the clock. What is the frame rate to use in order to have the hour hand move clockwise, the minute hand stay still and the second hand move counter clockwise in the video? Consider the sampling theory for the clock with three hands (i.e., the hour hand, the minute hand,Explanation / Answer
The dt system expression
The key to frame rate independence is the dt system expression.
dt stands fordelta-time. Delta means a change in a quantity, so delta-time means the change in time.
It is the time, in seconds, since the last tick.
For example, at 100 fps dt will be 0.01 (one hundredth of a second), and at 10 fps dt will be 0.1 (one tenth of a second).
In practice, dt varies tick-by-tick, so it is unlikely to be exactly the same value for long periods of time.
How to use dt
Every tick (once per frame), the object moves one pixel to the right.
Notice that at 30 FPS this means 30 pixels per second, and at 60 FPS this means 60 pixels per second. Those are different speeds, depending on the framerate.
The object will move to the right at 60 pixels per second at any framerate.
Since dt adds up to 1 every second, 60 * dt adds to up to 60 every second. This means at both 30 FPS and 60 FPS our object moves to the right 60 pixels every second - the same speed, regardless of framerate.
By default it does not use dt, and therefore is framerate dependent.
This is because dt usually has small random variations. These variations can make the same setup in a physics game give different results even if exactly the same thing is done twice.
This is often annoying for physics games, so by default it is framerate dependent. However, you can enable use of dt by using the Set Stepping Mode physics action on start of layout, and choose Framerate independent.
Time scaling allows you to change the rate time passes at in the game, also known as the time scale. You can set the time scale with the system Set Time Scale action.
A time scale of 1 means normal speed. 0.5 means half as fast, and 2.0 means twice as fast. If you set your game's time scale to 0.1, it's going ten times slower but still smoothly - a nice slow-motion effect!
Time scaling works by changing the value returned by dt. This means behaviors are affected, and any movement using dt. If you don't use dt in your movement calculations
The motion is not affected by the time scale! So to use time scaling, you simply have to use dt properly in all movement.
setting the time scale to 0 will stop everything in the game. If you have not used it correctly, some objects might continue to move, even though the game is supposed to be paused! In that case you can check how those objects are moved, and make sure you are using dt properly.
You want to accelerate the object by 100 pixels per second over one second. You simply need to add 100 * dt to the object's speed variable every tick, and it will accelerate in a framerate independent way. In other words, you use dt both to adjust the object's position, and to adjust the object's speed.
Minimum framerate
At very low framerates, dt can become very large. For example, at 5 FPS, dt is 0.2. An object moving at 500 pixels per second is therefore moving 100 pixels per tick.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.