Ashen Melee Combat uses Attributes (F_Attribute
) to store, calculate, and modify gameplay-related floating-point values. These values can describe any trait of their owners, such as a character's remaining health points, a character’s movement speed, or the amount of times a character has been hit. Actors store their Attributes in an their Attributes Component, which helps to manage Attributes for the owning actor of the component.
Attributes
Attributes keep a few different values stored. The current value, base value, increment value, & multiplier value. The "current" value is commonly used in calculations and logic that use and can be affected by any Gameplay Effects that are currently active, while the "base" value is more likely to remain fixed for a longer period. As an example, a "Health" attribute might have a base value of 100.0, but if the character has an active Gameplay Effect, for example, that poisons the character & applies damage to health over time the value will be much lower but the base will remain the same.
Creating Attributes
To create Attributes, you can open the character info data assets such as the PlayerInfo data asset or the EnemyInfo data asset. You can then add your base Attribute values. To add a completely new attribute select the “+” icon and specify the attribute gameplay tag & value. If the attribute does not have an associated tag, simply create a new gameplay tag for the attribute.
Associated Attributes
Attributes can also govern any number of other attributes. This is known as Associated Attributes. For example, you can create an endurance attribute and add Stamina as an associated attribute & change the stamina value based on the current value of the endurance attribute.
Initializing Attributes
The attributes system must be initialized on begin play from the Actor that is using the attributes component. The order in which this function is called is important for characters using a bunch of components together. For reference on when to call initialize attributes component in relation to other components check the default character BP included in the project.
Reading Attribute Values
Get Attribute By Tag:
Returns the F_Attribute for the attribute associated with the specified input tag.
@Attribute Tag - specify which attribute is returned by the function
Get Base Attribute Value:
Returns the base value for the attribute associated with the specified input tag.
@Attribute Tag - specify which attribute is returned by the function
Get Current Attribute Value:
Returns the current value for the attribute associated with the specified input tag.
@Attribute Tag - specify which attribute is returned by the function
Get Max Attribute Value:
Returns the max value for the attribute associated with the specified input tag.
@Attribute Tag - specify which attribute is returned by the function