Description
The Relative
property of the RealTimeSince
struct provides the time that has passed since the last reset, measured in seconds. This property is useful for tracking elapsed time in a straightforward manner, allowing developers to easily determine how much time has passed since a particular event occurred.
Usage
To use the Relative
property, you typically initialize a RealTimeSince
variable to zero when an event occurs. The Relative
property will then automatically update to reflect the time elapsed since that initialization. This can be particularly useful for timing events or implementing cooldowns in a game.
Example usage:
RealTimeSince lastActionTime = 0;
// In an update loop or method
if (lastActionTime > 5.0f)
{
// Perform an action if more than 5 seconds have passed since last reset
lastActionTime = 0; // Reset the timer
}
Example
RealTimeSince lastActionTime = 0;
// In an update loop or method
if (lastActionTime > 5.0f)
{
// Perform an action if more than 5 seconds have passed since last reset
lastActionTime = 0; // Reset the timer
}