Download

How to set Timers in C++?


FTimerHandle TimerHandle;
GetWorldTimerManager().SetTimer(TimerHandle, &ASomeCharacter::SomeFunction, 1.0f, true, 1.0f);



GetWorldTimerManager().ClearTimer(TimerHandle);

Is this a proper function call for FTimerManager?
If not, please correct this code :smiley:

You need to pass in the object whose function you are binding to also. So assuming you were calling from within the ASomeCharacter class:



GetWorldTimerManager().SetTimer(TimerHandle, this, &ASomeCharacter::SomeFunction, 1.0f, true, 1.0f);


Alternatively, instead of an object and a method, you can just pass FTimerDelegate::Create*(…) as the second parameter, to bind in a variety of different ways.