Timers
Timers in Unreal Engine 4 allow you to perform actions after a delay or every X number of seconds. In the case of the SuperSideScroller
potion power-up, a timer will be used to restore the player's movement and jump to their defaults after 8 seconds.
Note
In Blueprints, you can use a Delay node in addition to Timer Handles to achieve the same results. However, in C++, Timers are the best means to achieve delays and reoccurring logic.
Timers are managed by Timer Manager
, or FTimerManager
, which exists in the UWorld
object. There are two main functions that you will be using from the FTimerManager
class, called SetTimer()
and ClearTimer()
:
void SetTimer ( FTimerHandle & InOutHandle, TFunction < void )> && Callback, float InRate, bool InbLoop, float InFirstDelay ) void ClearTimer(FTimerHandle& InHandle)
You may have...