What is the Unity Time Class? How is it Used?
What is the Unity Time Class? How is it Used?
Unity has libraries and classes that make our work much easier, and one of these classes is the Time class.
By using the Time class, we can easily do many things that would be hard to fix normally. Let's take a detailed look at what the Time class is for.
With the Time library, you can change the game's time, make the character's fps-based movement more stable, and have the same speed across all devices. We use the Time library for many features like these.
When using the Time library, you start with "Time." and then select the feature you need.
Time.timeScale = 0.2f;
Just like in the command above for setting game time.
With the "timeScale" property, you can set the game time/speed. So, what other features are there?
captureDeltaTime : Slows the game's time down to ensure that frames are clear when taking screenshots.
captureFramerate : Restores the slowed game time, which was slowed with captureDeltaTime, to its normal state.
deltaTime : Gets the completion time that has elapsed since the last frame, in seconds.
fixedDeltaTime : The interval in seconds that physics and other frame updates are performed. (Friends, you can think of this as similar to FixedUpdate when writing scripts.)
fixedTime : The time when the last FixedUpdate started, the total time in seconds since the game started.
fixedUnscaledDeltaTime : Shows the time in seconds that has passed until the last frame becomes active, independent of the game's time scale.
fixedUnscaledTime : The time interval, independent of game time, at which the last FixedUpdate was started, readable in seconds.
frameCount : You can think of this as the FPS value in games, it shows how many frames have passed.
inFixedTimeStep : The state loop of fixed time, similar to FixedUpdate—returns True if called, and False if not.
maximumDeltaTime : The longest time a frame can take, in updates like FixedUpdate, the time per frame will be the same.
maximumParticleDeltaTime : The longest time a frame can use for particle updates. (Think of this like how many frames the fire in a fire effect can appear at most.)
realtimeSinceStartup : The time in seconds since the game started.
smoothDeltaTime : I can't comment on this one as I've never used it, friends...
time : The time in seconds since the game started.
timeScale : The speed of the game; 0 means the game stops and nothing moves, 0 - 1 is slow, 1 is normal, and above 1 is fast motion.
You can use timeScale to create slow-motion scenes in your game.
timeSinceLevelLoad : The time that has elapsed since the frame started and the last scene was loaded.
unscaledDeltaTime : The random interval in seconds between the last frame and the activation of the next frame.
unscaledTime : Independent of frames, the time in seconds since the game started.
I tried to explain these features as best as I could, but you can best understand the differences by using them.
For more detailed information about the class features above, I suggest you check Unity's official documentation page.


Yorum Gönder