FTimerManager::GetTimerElapsed
#include "TimerManager.h"
Access: public
Specifiers: inline
Description
Returns the time in seconds that has elapsed since the timer last fired (or since it was set, for a timer that has not yet fired). Returns -1.0f if the timer does not exist.
Caveats & Gotchas
- • For looping timers, elapsed time resets to 0 each time the timer fires. If you call this immediately after a callback you may get a very small near-zero value, not the full interval.
- • Elapsed time is derived from InternalTime, which is the timer manager's own clock, not game world time. If the world is paused at the engine level but the timer manager is still ticked (e.g. by a game instance), elapsed will still advance.
Signature
inline float GetTimerElapsed(FTimerHandle InHandle) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InHandle | FTimerHandle | Handle to the timer whose elapsed time to retrieve. | — |
Return Type
float Example
Drive a progress bar from elapsed time C++
float AMyActor::GetCooldownProgress() const
{
FTimerManager& TM = GetWorld()->GetTimerManager();
float Rate = TM.GetTimerRate(CooldownHandle);
float Elapsed = TM.GetTimerElapsed(CooldownHandle);
if (Rate > 0.f && Elapsed >= 0.f)
{
return FMath::Clamp(Elapsed / Rate, 0.f, 1.f);
}
return 0.f;
} Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?