Creating and Clearing Timers
The steps below will show you how you can create/set a Timer in Blueprints.
For this example, we are using the Blueprint Third Person Template and will be causing fire damage to the player over time.
Inside your project, open the ThirdPersonCharacter Blueprint.
Right-click in the graph and add two Custom Events called PlayerInFire and PlayerNotInFire.
In the MyBlueprint window, add a new Function called FireDamage.
This Function will be called over time by the Timer and will apply the damage.
Drag off the PlayerInFire Event and add the Set Timer by Function Name node.
Drag off the PlayerNotInFire Event and add the Clear Timer by Handle node.
For Set Timer by Function Name, set the Function Name to FireDamage.
On the Set Timer, set the Time to 0.75 and check the Looping box.
Connect the Return Value pin of the Set Timer by Function Name node to the Handle pin of the Clear Timer by Handle node.
The Time entered is the interval in which the Function Name Function will be called (every 0.75 seconds).
Create a new Integer variable called PlayerHealth, click Compile, then set the Default Value to 100.
Inside the FireDamage Function, while holding down the Alt key, drag the PlayerHealth variable into the graph.
Hold down Control and drag in the PlayerHealth variable as well.
Drag off the PlayerHealth variable and add an Integer - Integer node, then off the 0 pin, add a Random Integer in Range node.
We used a Random Integer in Range node with Min (1) and Max (4) values, however you can enter a damage value if you wish.
Off the Set node, add a Print String then Control drag in PlayerHealth and connect it to the Print String.
We are not displaying Health Bars in this example; however this will show us that the Health Value is indeed decreasing.
Open the Blueprint_Effect_Fire Blueprint located in the Content/StarterContent/Blueprints folder.
Click the Add Component button and add a Box shape and call it Trigger.
When the player enters/exits this Trigger, we will call the Events in the ThirdPersonCharacter Blueprint.
Locate the My Blueprint tab and Right-click on the Trigger and add the OnComponentBegin and OnComponentEnd Overlap Events.
Drag off the Other Actor pin of each and add the Cast To ThirdPersonCharacter node.
Drag off the As Third Person Character C pin and (for the Begin node) add PlayerInFire and (for the End node) PlayerIsNotInFire Events.
Compile and Save, then close the Blueprint.
In the Content Browser, drag the Blueprint_Effect_Fire Blueprint into the level.
When you click the Play button to play in the editor, enter the fire and you should see you start to take damage.
This is an example of how you could use timers to create a damage-over-time effect; however you could use timers to represent other things such as a power-up that lasts for X seconds which allows the player to be invincible or have some other ability.