Etheri Dev Log#3: Creating attributes and setting them.
- camjhill737
- Feb 20
- 1 min read
I added health and mana variables to my attribute set class. What I found interesting about this process is that the GAS system recommends you to use their own struct called FGameplayAttributeData for creating attribute variables.
What this struct contains is two float variables called base value and current value. Important to note base value is not the max value it simply represents the value amount of your attribute when you load up the game. To create a max value you have to create another attribute for that so its classic programming still, Health and MaxHealth.
Something really helpful I found in the attribute set header class is this macro

In my previous project I remember creating a lot of force inline getters and setters but the Attribute_Accessors macro creates these getter and setters for you.

This allows me to simply call Init health and mana to initialise these properties.
Since I now have health I decided to create a health potion. This is a temporary implementation because I'm using a const_cast to get around a const variable which is the ability system component.

Pretty basic setup created an overlap ufunction that is bound to on component begin overlap. After the const is removed I'm just adding 25 to health.
I dont have any UI at the moment so I'm using the command showdebug abilitysystem which shows you your attributes all are initlialised and the potion works as intended.
Comments