RealDocs

FTimerManager::SetTimer

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

Description

Schedules a member function to fire after InRate seconds. If InbLoop is true, the callback repeats indefinitely. Passing InRate <= 0.f clears any existing timer on InOutHandle.

Signature

template<class UserClass> void SetTimer( FTimerHandle& InOutHandle, UserClass* InObj, void (UserClass::*InTimerMethod)(), float InRate, bool InbLoop = false, float InFirstDelay = -1.f )

Parameters

Name Type Description Default
InOutHandle FTimerHandle& If it refers to an existing timer, that timer is replaced. On return holds the handle for the new timer.
InObj UserClass* The UObject instance whose method will be called.
InTimerMethod void (UserClass::*)() The member function to call when the timer fires.
InRate float Seconds between set and fire. If <= 0.f, clears any existing timer on InOutHandle.
InbLoop bool If true, the timer repeats every InRate seconds. false
InFirstDelay float For looping timers: delay before the first fire. If < 0.f, InRate is used. -1.f

Return Type

void

Caveats & Gotchas

  • Overloads exist for FTimerDelegate, FTimerDynamicDelegate, TFunction<void()>, and a no-delegate version for poll-only use. All route to the same internal implementation.
  • Replacing a running timer via the same handle is safe — the old timer is silently discarded without firing a final callback.
  • InFirstDelay only applies to looping timers; single-shot timers always wait InRate seconds.

Examples

Repeating timer with a member function C++
GetWorldTimerManager().SetTimer(
	RegenHandle,
	this,
	&AMyCharacter::RegenerateHealth,
	1.0f,  // every 1 second
	true   // loop
);
One-shot timer with a lambda C++
FTimerHandle Handle;
GetWorld()->GetTimerManager().SetTimer(
	Handle,
	[this]() { SpawnExplosion(); },
	3.0f,   // fires after 3 seconds
	false   // no loop
);

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.