top of page
Search

Etheri Dev Log#3: Creating attributes and setting them.

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

Attribute_Accessors macro
Attribute_Accessors 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.

how to implement the macro
how to implement the macro

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.

Get attribute set returns const but set health requires a none const attribute set to access it.
Get attribute set returns const but set health requires a none const attribute set to access it.

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.



Proof the const cast didnt cause any undefined behaviour

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


bottom of page