float Relative { get; set; }

robot_2Generated
code_blocksInput

Description

The Relative property of the TimeSince 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 specific event occurred.

Usage

To use the Relative property, you typically initialize a TimeSince 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:

TimeSince timeSinceLastAction = 0;

// In an update loop or method
if (timeSinceLastAction > 5.0f)
{
    // Perform an action if more than 5 seconds have passed
    timeSinceLastAction = 0; // Reset the timer
}

Example

TimeSince timeSinceLastAction = 0;

// In an update loop or method
if (timeSinceLastAction > 5.0f)
{
    // Perform an action if more than 5 seconds have passed
    timeSinceLastAction = 0; // Reset the timer
}