The F_Attribute struct in the Advanced Attributes System is the core data structure for storing and managing gameplay-related floating-point attribute values, such as health, stamina, or experience points, within the BP_AttributesComponent. It enables developers to define and track actor traits efficiently, supporting dynamic modifications and relationships like souls-like leveling. The struct addresses the need for a flexible, standardized way to handle attribute data in Action RPGs, ensuring seamless integration with other system features like HUD displays and associated attributes.
Basic Usage
The F_Attribute struct is managed within the Attributes array of the BP_AttributesComponent. Below are the primary methods for interacting with F_Attribute in Blueprints.
-
SetCurrentAttributeValue:
- Purpose: Sets the current value of an
F_Attributefor gameplay logic. - Usage: Call
SetCurrentAttributeValueonBP_AttributesComponent, specifying theAttributeTagand value.
- Purpose: Sets the current value of an
-
GetCurrentAttributeValue:
- Purpose: Retrieves the current value of an
F_Attributefor use in gameplay or UI. - Usage: Use
GetCurrentAttributeValueonBP_AttributesComponentwith theAttributeTag.
- Purpose: Retrieves the current value of an
-
ModifyAttribute:
- Purpose: Dynamically adjusts the current value of an
F_Attributeduring gameplay. - Usage: Call
ModifyAttributeonBP_AttributesComponentto add or subtract a value.
- Purpose: Dynamically adjusts the current value of an
Key Properties
| Property Name | Purpose |
|---|---|
AttributeTag | The Gameplay Tag identifying the attribute (e.g., Attribute.Health). |
CurrentValue | The dynamic value used in calculations, affected by modifiers (e.g., current health). |
BaseValue | The fixed reference value, unaffected by temporary modifiers (e.g., max health). |
MultiplierValue | Stores multiplication factors applied to the attribute via modifiers. |
PercentValue | Tracks the percentage of the current value relative to the max (e.g., health percentage). |
AssociatedAttributes | A map linking governed attributes to Curve Table rows for dynamic scaling (e.g., Attribute.Endurance to Attribute.Stamina). |
Key Concepts
Attribute Value Types
The F_Attribute struct distinguishes between CurrentValue and BaseValue to support dynamic gameplay. CurrentValue reflects real-time changes (e.g., health reduced by damage), while BaseValue remains stable for reference (e.g., max health). This separation enables flexible attribute management without losing baseline data.
- Purpose: Supports dynamic and static attribute tracking.
- Usage: Use
GetCurrentAttributeValuefor gameplay logic andGetBaseAttributeValuefor reference checks. - Benefit: Simplifies handling of temporary modifiers and persistent data.
Percentage Tracking
The PercentValue property stores the current value as a percentage of the max, useful for UI displays or save/load systems. For example, it can represent current health divided by max health, ensuring accurate restoration after loading.
- Purpose: Facilitates UI updates and data persistence.
- Usage: Access
PercentValueviaBP_AttributesComponentgetters for HUD widgets. - Benefit: Streamlines progress bar integration and save system compatibility.
Associated Attributes Integration
The Associated Attributes map in F_Attribute allows attributes to govern others using Curve Tables, enabling souls-like leveling mechanics. This integrates seamlessly with the Associated Attributes feature for dynamic scaling.
- Purpose: Enables complex attribute relationships.
- Usage: Configure
AssociatedAttributesinBP_AttributesComponentto link attributes. - Benefit: Reduces manual scripting for leveling systems.
Best Practices
- Workflows:
- Define
AttributeTagvalues clearly in the Gameplay Tags table to avoid conflicts. - Use
SetCurrentAttributeValuefor initial setup andModifyAttributefor runtime changes.
- Define
- Pitfalls to Avoid:
- Don’t modify
BaseValuedirectly during gameplay; useCurrentValuefor dynamic changes. - Avoid duplicate
AttributeTagentries in theAttributesarray to prevent errors.
- Don’t modify
- Performance Considerations:
- Limit the number of
AssociatedAttributesentries to reduce curve calculations. - Cache frequently accessed
CurrentValueresults in Blueprints to optimize performance.
- Limit the number of