![]() Get Timer Elapsed and Get Timer Remaining While the Set Timer by Function Name and Clear Timer by Handle nodes are used to start/stop a Timer, the nodes below may also be of use based on your needs. 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. When you click the Play button to play in the editor, enter the fire and you should see you start to take damage. In the Content Browser, drag the Blueprint_Effect_Fire Blueprint into the level. Locate the My Blueprint tab and Right-click on the Trigger and add the OnComponentBegin and OnComponentEnd Overlap Events.ĭrag off the Other Actor pin of each and add the Cast To ThirdPersonCharacter node.ĭrag off the As Third Person Character C pin and (for the Begin node) add PlayerInFire and (for the End node) PlayerIsNotInFire Events.Ĭompile and Save, then close the Blueprint. When the player enters/exits this Trigger, we will call the Events in the ThirdPersonCharacter Blueprint. Open the Blueprint_Effect_Fire Blueprint located in the Content/StarterContent/Blueprints folder.Ĭlick the Add Component button and add a Box shape and call it Trigger. We are not displaying Health Bars in this example however this will show us that the Health Value is indeed decreasing. Off the Set node, add a Print String then Control drag in PlayerHealth and connect it to the Print String. 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. Hold down Control and drag in the PlayerHealth variable as well.ĭrag off the PlayerHealth variable and add an Integer - Integer node, then off the 0 pin, add a Random Integer in Range node. Inside the FireDamage Function, while holding down the Alt key, drag the PlayerHealth variable into the graph. The Time entered is the interval in which the Function Name Function will be called (every 0.75 seconds).Ĭreate a new Integer variable called PlayerHealth, click Compile, then set the Default Value to 100. On the Set Timer, set the Time to 0.75 and check the Looping box.Ĭonnect the Return Value pin of the Set Timer by Function Name node to the Handle pin of the Clear Timer by Handle node. This Function will be called over time by the Timer and will apply the damage.ĭrag off the PlayerInFire Event and add the Set Timer by Function Name node.ĭrag off the PlayerNotInFire Event and add the Clear Timer by Handle node.įor Set Timer by Function Name, set the Function Name to FireDamage. ![]() ![]() In the MyBlueprint window, add a new Function called FireDamage. Right-click in the graph and add two Custom Events called PlayerInFire and PlayerNotInFire. Inside your project, open the ThirdPersonCharacter Blueprint. ![]() For this example, we are using the Blueprint Third Person Template and will be causing fire damage to the player over time. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |