6. Create Stat Change Area with Interaction Component {{ currentPage ? currentPage.title : "" }}

1. Create a new Blueprint and select as Class SP8_Area_StatChange.

Do not forget to set the Interaction Profile inside the Blueprint SP8_Area like descriped inside this Tutorial, if you haven’t done it yet!

2. Create a new GameplayTag and call it Area.Types.StatChange.

3. Open your new Blueprint and go to the Class Defaults and set your Area Type to your new Gameplay Tag.

4. Simply drag and drop your new Blueprint to your Level.

5. Select your Area inside the Outliner of your Level and set following Options inside the Details Panel:

  • Add one Item to Stat Change Options. You can add multiple if you want.

    • Decide a Type you want to use:

      • HealCustomStat: Heals a Custom Stat every <Interval> seconds.

      • ReduceCustomStat: Reduce a Custom Stat every <Interval> seconds.

      • AddSecondaryStatValue: Add a Value to a Secondary Stat.

      • ReduceSecondaryStatValue: Reduce a Value from a Secondary Stat.

      • AddSecondaryStatValuePercentage: Add a Value to a Secondary Stat (10 Amount means 10% if the current Value will be added).

      • ReduceSecondaryStatValuePercentage: Reduce a Value from a Secondary Stat (10 Amount means 10% of the current Value will be reduced).

      • SetSecondaryStat: Overwrites the current Value of the Secondary Stat with the Amount.

    • StatType: Which Stat Type should be changed.

    • Amount: What Amount should be added, removed or set.

  • Interval: Only if you are using HealCustomStat or/and ReduceCustomStat. In what Interval should those happen?

In this example, if the Player enters the Area, his Health will be regenerated every second by 300.

What will happen, if I put multiple changes on the same Secondary Stat?

Let’s take following example on the Stat Damage (Current Amount without the Area is 100):

  • ReduceSecondaryStatValuePercentage: 50

  • AddSecondaryStatValue: 100

  • ReduceSecondaryStat: 60

  • AddSecondaryStatValuePercentage: 200

  • SetSecondaryStat: 500

  • AddSecondaryStatValue: 200

  • SetSecondaryStat: 1000

The Calculations work like that:

  • 100 - 100 * 50 / 100 = 50 (CurrentValue - CurrentValue * ValueOfArea / 100)

  • 50 + 100 = 150 (newCurrentValue + ValueOfArea)

  • 150 - 60 = 110 (newCurrentValue - ValueOfArea)

  • 110 + 110 * 200 / 100 = 330 (newCurrentValue + newCurrentValue * ValueOfArea / 100)

  • Overwrite to new Value of 500

  • Will not be called, because of SetSecondaryStat!

  • Will also not be called, because of SetSecondaryStat

The Value of Damage inside this Area would be 500.

Setup the Player

1. With PlayerTemplate Go into your PlayerBP under Class Defaults and set Area Type Chat to your Gameplay Tag Area.Types.Chat.

With PlayerTemplate You are done, because everything is setup.

2. We should now listen to the Dispatcher AreaEntered on the Interaction Component and do following:

  • First of all check if the Area Type is Area.Types.StatChange.

  • Then call the Interface Function SP8_AddPlayerToStatChange on the Area.

    • This will add the Player to the Area, which will call on the Stat Component every Change.

3. Now we have to do the same with AreaLeft.

Only difference, we have to remove the Player from the Area.

It is simple, if we enter the Area, the Area will change the Stats however you have set the Stat Change Options.

If you leave, the change will be resetted and the Interval stoped.

{{{ content }}}