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...