Here is a thread about the same question: SetTimer with parameters
Let me link a piece of code from that thread:
void AMyGameMode::RespawnPlayerWithDelay(APlayerController * Player)
{
const float Interval = 3.f;
const bool Loop = false;
const float FirstDelay = 0.f;
FTimerHandle UniqueHandle;
FTimerDelegate RespawnDelegate = FTimerDelegate::CreateUObject( this, &AMyGameMode::RespawnPlayer, Player );
GetWorldTimerManager().SetTimer( UniqueHandle, RespawnDelegate, Interval, Loop, FirstDelay );
}
Its essentially the same as what Fred K posted, but seeing the FTimerDelegate on a seperate line may clear things up for you. **Edit: ** Added more variables to the example code for sake of readability.
An FTimerHandle is not a function, it is simply an ID that you create to reference a timer that you create with SetTimer(). An FTimerDelegate in the above code is a wrapper around a function plus any arguments that should be passed to it. Now, by calling SetTimer with a created FTimerHandle and FTimerDelegate, it results in the function call represented by FTimerDelegate to be called after a delay/periodically based on the other parameters you pass to SetTimer. If you want to stop the timer later, you need to store the FTimerHandle and call ClearTimer(MyTimerHandle) where MyTimerHandle is the handle you called SetTimer with before. Be aware that in the above example the FTimerHandle isn’t being stored, because the timer just triggers once and does not need to be stopped.