Getting & Setting Stats
Learn how to make changes to stats.
Last updated
Learn how to make changes to stats.
Last updated
Remember to use Esper.SkillTree.Stats
namespace when scripting with stats.
You can access stats by getting the UnitStatsProvider
component of a GameObject
.
Here's how you can get a stat called 'HP':
You can get a stat by both its full name and abbreviation. The GetStat
method returns an UpgradableStat
.
There are a few key values of an UpgradableStat
to take note of.
Name | Description |
---|---|
The current and current max values can be used to keep track of the unit's stat changes. For the HP example, the currentValue
would be the unit's current HP, which should decrease as the unit gets damaged. The currentMaxValue
would be the unit's HP without any damage taken.
These values can be changed by Upgrading Stats.
The current value should be updated manually as required by your game. You can set the current value in multiple ways.
baseValue
The base value of the stat. Automatically updated when the stat level is changed.
currentValue
The current value of the stat. Requires manual updates.
currentMaxValue
The max value that the current value can go up to. Automatically updated when the stat level is changed.