Getting the current time
To get the current time, use ITimer::GetCurrTime. This returns a CTimeValue object representing the time in seconds since game start. This can be used to determine the time between two events. For example:
void StoreTime() { m_storedTime = gEnv->pTimer->GetCurrTime(); } void CheckTimePassed() { // Now check time that has passed since stored if(gEnv->pTimer->GetCurrTime() - m_storedTime > 3.f) { CryLogAlways("Three seconds have passed"); } }
Keep in mind that the current time is only updated once a frame, if you need to check the exact time at the current instant, use ITimer::GetAsyncTime. Note that this will query the time immediately, resulting in the function being much slower than ITimer::GetCurrTime.
Getting the delta/frame time
Most update functions part of the engine will provide the frame time as a parameter, but in the case that it is not, you can call ITimer::GetFrameTime.
Time Scale
Time in the engine is multiplied by the t_scale CVar, allowing us to slow down or speed up game play. By default, the time scale is set to 1 (100%). To speed up the game, we could use:
t_scale 2
...Resulting in a 2x speed-up of game time, including every frame's delta. To retrieve the current time scale, see ITimer::GetTimeScale.
Conclusion
This concludes the article on Time. You may be interested in: