RealDocs

FTimerManager::GetTimerRate

function Engine Since 4.0
#include "TimerManager.h"
Access: public Specifiers: inline

Description

Returns the configured repeat interval (in seconds) of the specified timer. Returns -1.0f if the timer does not exist.

Caveats & Gotchas

  • Returns -1.0f for both invalid handles and for timers that have been set without a rate (e.g. SetTimerForNextTick). Always check the return value before using it.
  • The rate is the interval between repeats for looping timers, but the first fire may use a different delay if InFirstDelay was specified when the timer was set.

Signature

inline float GetTimerRate(FTimerHandle InHandle) const

Parameters

Name Type Description Default
InHandle FTimerHandle Handle to the timer whose rate to retrieve.

Return Type

float

Example

Display timer rate in debug UI C++
void AMyActor::DebugTimerInfo()
{
    float Rate = GetWorld()->GetTimerManager().GetTimerRate(AttackTimerHandle);
    if (Rate >= 0.f)
    {
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green,
            FString::Printf(TEXT("Attack timer fires every %.2f seconds"), Rate));
    }
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.