My Speicific question in Picture:
What I know about ‘time.deltaTime’ is that it used to workout with the frames and end them at exactly same time.
No matter how difference in performance among the computers
Computer A 60fps
Computer B 30fps
Here are my questions
what is ‘Time.deltaTime’ and how it calculated mathematically, but I think this is more like should discover how this API work.
What makes run the computers in same time.
What is concept of Delta.
Are Delta and DeltaTime related?
- Time.deltaTime is the amount of seconds it took for the engine to process the previous frame. It’s calculation is rather simple: it uses the system’s internal clock to compare the system time when the engine started processing the previous frame to the system time when the engine started processing the current frame. Every motherboard has a “system clock” which is responsible to keep track of time. Operating systems have access to that system clock and provide API’s to read that clock. And Unity gets the time from that API and that’s how things are synchronized.
- Think of a game as a movie, which is essentially a sequence of images. The difference is that a movie is rendered at a fixed rate of 24 images per second, while a game doesn’t have a fixed frame rate.
In a movie, if a car travels at 1 meter per second, each image will make it move by 1/24 meter, and after 24 images (1 second) the car will have traveled exactly 1 meter. It’s easy because we know that each frame takes exactly 1/24 second.
In a game, we have to do the same thing, except the frame rate varies. Some frames can take 1/60 second, some others can take 1/10 second. We can’t use a fixed ratio. Instead of a fixed number we have to use Time.deltaTime. Each frame, the car will move a distance proportional to the time of the frame. After roughly 1 second, the car will have traveled roughly 1 meter
- Delta is the mathematical symbol for a finite difference. Its use is very common in english when talking about something that changed over time.
- deltaTime is a difference of time, so it’s a Delta
Delta basically means difference. DeltaTime is the difference in time that it took from the time it took the second previous frame to finish to the time the previous frame finished. Since you mustn’t know how long your current frame will be, the best bet is the last one.
This means, no matter how fast or slow a machine is, DeltaTime is smaller or larger accordingly, basically adjusting calculations always to / per second. The more genes the smaller deltatime and therefore the steps in calculation it’s used in. Always adjusting to an equal experience.
How low level do you want to know? Every computer runs at some frequency. There’s a clock register (address in memory that stores the current tick) that is converted internally by the API that Unity uses. Unity then does its own time management and stores that into its Time class.
Basically, deltaTime is the time in seconds that has passed since the last frame. So say you want an object to move 100 pixels in 1 second. You can determine the distance by multiplying 100 by the deltaTime. The cool part is that if exactly 1 second passed, then 100 x 1 = 100. Let’s say the last frame took 0.5 seconds, then 100 x 0.5 is 50. If two frames go by, 0.5 seconds each, then the time that has passed is 1 second, because 0.5 + 0.5 = 1. And the distance for those two frames is 100 because 50 + 50 = 100.
Delta means the measurement of some value relative to the last measurement taken. In my example above with the two frames equaling 1 second, the first delta was 0.5, and so was the second. So with this, the unit of measurement of the delta, is time.
Maybe this will clarify what the difference between Computer A and Computer B is. Computer B is obviously slower than Computer A. That means Computer A can process a lot more data in the same amount of time as Computer B. HOWEVER, internally, none of this effects the clock keeping track of time. One second is still one second, no matter how fast or how slow the computer is. Because of this, we can take snapshots of the time that has passed between program cycles (delta time). From there it’s just a matter of using the whole distance = rate * time formula. By using this formula it doesn’t matter if 60 frames passed, or 600 frames, an object traveling at a rate of 100 pixels per second, will still reach 100 pixels in one second.
First, Time.deltaTime is the completion time in seconds since the last frame.
Time.DeltaTime = 1/fps
Therefore, when fps is 60, Time.deltaTime is = 0.0166666 seconds.
Second, Lets take an example:
transform.Translate(Time.deltaTime , 0 , 0);
Lets say the fps is 60. Time for each frame is 0.016666666. The distance moved by object in 1 second is 1 unit(0.0166666*60 frames)
If the fps is 30, i.e. 30 frames in one second, time for each frame is 0.03333. The distance moved by object in 1 second is 1 unit(0.03333*30 frames)
Therefore using deltaTime, make the object move through the same distance on different devices.
Third, Delta mathematically means difference.
Fourth, deltaTime is the difference of time of this frame and the previous frame. Thus is mathematically a delta.
For more information, go through the following link: