Answer the question
In order to leave comments, you need to log in
Delta Time or Fixed Delta Time?
I need to time the high score table.
The time is stored in a variable as The score = score + Time.deltaTime;
question is how to time correctly?
Should I use Time.DeltaTime or Time.FixedDeltaTime?
Accuracy is one of the indicators.
Answer the question
In order to leave comments, you need to log in
It is most accurate to save DateTime.Now during the start , and at the moment the timer stops, take the DateTime again, subtract the first from the second and get the TimeSpan , and then you can do whatever you want. This is the most flexible option, but DateTime does not know anything about Time.timeScale , if you want to take into account the deceleration-acceleration of time, then take Time.time and measure the start and finish of the timer in the same way. Plus deltaTime is very unreliable.
Exactly - Time.time. But these two can. In your case, deltaTime if Update, and fixedDeltaTime if FixedUpdate.
What is deltaTime and fixedDeltaTime can be easily found on the first link in Google
here it is important to clarify that even the documentation mentions that deltaTime itself "mutates" (begins to be considered as fixedDeltaTime) into fixedDeltaTime, if you use it in FixedUpdate. so you don’t have to bother with this)
deltaTime is the time between frames (for which you can only get), so here the accuracy can sag along with performance)
fixedDeltaTime - fixed from the name (more precisely, it tries to meet and call each time, but essence) the interval set in the editor, but it is not worth reducing it manually - since a miscalculation of physics is tied to it.
In fact, how important is accuracy to you?
If it’s right to fractions of a second, then you need to detect time through something systemic) in the spirit of timers that measure the performance of methods in code, etc.)
If you have an error of 1/30 of a second .. plus minus .. not critical) then just add your timer on Update and don’t suffer)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question