Dealing with rates and timing of actions

Hello all,

I am trying to use methods of timing different actions in my scripts. For example, the way I am currently timing something (Note, the incorrect way, as it does not work on other systems), is to count the number of frames past and then perform an action. For example, if I wanted after 5 seconds for something to happen, I would count 300 seconds and then do the action. However, if the FPS is not capped at 60 fps, this action performs earlier than wanted.

What is the proper way of doing these time calculations?


You can take a look at Coroutines, they have a WaitForSeconds

You can also do a timer in the Update method that use the deltatime

I recommend using an external DLL call to a microsecond accurate C timer for that.