1. Home
  2. Foliage Plugin
  3. Bonus Examples
  4. Health

Health

This example will show you how to use a Health value to decrement before giving resources to the player.

fOLIAGE aCTOR sETUP

First open up your BP_FoliageActor blueprint and override the “Handle Foliage Damage” function, this will override the default behavior of the Damage event and lets you add your own custom logic to it.

Next add a “Health” variable of type float, set it to a default value of 100 and make it Replicated (if you’re making a multiplayer game)

Here is the logic that we’re going to be using in the “Handle Foliage Damage” function that we overrode in the previous step, this will reduce the Health value every time the foliage takes damage and if the health value reaches 0 we will apply damage and give the player their reward.

The important step here is to reset the Health value to 100 once it’s been reduced to 0, also don’t forget to “call parent function

You can add the “Parent:” function by “Right Clicking” the “Handle Foliage Damage” node and selecting “Add call to parent function” from the menu