- Home /
Global custom timer
Hi. I'm thinking about creating game timer similar to minecraft ticks. Like every 20-50ms there will be a game tick. And all game stuff will depend on these game ticks.
So, it will be a singleton or static class with simple timer and on every tick it will fire event notyfing all listeners that time unit(tick) passed.
Is this implementation ok or something better alerady exist?
What are possible downsides to this system?
Answer by rh_galaxy · Apr 26 at 12:42 AM
There are "ticks" already with Time.fixedDeltaTime (Project Settings->Time->Fixed Timestep), FixedUpdate() runs every time step. So you don't need to fire events and have listeners, it's already there for all MonoBehaviour objects.
The downside is that it is not run at true time intervals like frame rate, meaning a bunch of ticks can run back to back - to match up with the frame rate. I would not recommend setting it at 50 ms, rather set it to 10 ms, and do your stuff every 5 ticks.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Respawn timer? Duplicate instance OnDestroy question... 0 Answers
Which timer is more efficient ? 3 Answers
C#: Making a timer 1 Answer