🚀 Spring Sale is live! 🚀 Don't miss your chance to get all my products at 30% OFF!  

Get it!

Gameplay Attribute Basic

GameplayAttributes

Basic knowledge

Check https://github.com/tranek/GASDocumentation?tab=readme-ov-file#concepts-ge for the basic knowledge of gameplay attributes.

Gameplay Attribute In GGA

The GenericGameplayAttributes module of GGA provides a component called GGA_AttributeSystemComponen, The component is essentially a proxy of all the AttributeSets, and many of the events that occur with the AttributeSet are communicated externally through this component.

GGA provides a code generator for generating AttributeSets, and you basically don't need to modify the generated AttributeSets, which inform the external world of internal events through the GGA_AttributeSystemComponent so that you can process attributes in Blueprint/C++.

If your AttributeSet is not generated by GGA, you can also refer to the built-in AttributeSet and manually call the two functions on the attribute system component.

Processing attribute changes outside of the AttributeSet (e.g., in a blueprint) is not only feasible this way, but it works very well! I hate writing a bunch of logic in the AttributeSet.

check:Attribute System to learn more information, including how to generate AttributeSets through CodeGenerator.

Creating Gameplay Attribute Set

Refer to Attribute System

Initialize Gameplay Attributes

Instead of using GameplayEffect to init/modify existing gameplay attributes, you can also utilize AttributeInitter. GGA also exposed related API to blueprint so you can use it.

Prepare Curve Table

Create the .CSV file outside the engine and make sure your table structure is as follows:

gga guide 15

You can edit your .CSV curve table externally with any text editing software and import it into Unreal Engine.

I'm using VSCode here + ‘Edit CSV’ extension.

Where Row Name use this rule: ‘GroupName.AttributeSetClassName.AttributeName’. And make sure that the level column starts from 1.

Where the group name you can also create a sub category by using the ‘->’ symbol, e.g. Main->Generic.AS_Health.Health or Test->Generic.AS_Health.Health. Sub categories allow you to classify attributes more easily in the curve table. The subclassification allows you to more easily categorise attributes in the curve table.

Add Curve Table to Engine

Drag and drop the .csv file directly into the engine ContentBrowser to import it.

gga guide 16

Right click on the file and click CopyReference to get the path to the file in the engine, then fill in the following section in DefaultGame.ini:

1[/Script/GameplayAbilities.AbilitySystemGlobals]
2##Add a curve table to GlobalAttributeSetDefaultsTableNames arrays.
3+GlobalAttributeSetDefaultsTableNames=/Game/GenericGame/CombatSystem/Extras/DataTables/CT_GCS_DefaultStats

In UE5.5 and above, you can add curve tables graphically in the project settings.

gga guide 17

Through AbilitySystemComponent

You can configure the attribute initialization group name and level within the GGA_AbilitySystemComponent. During the invocation of InitializeAbilitySystem, all related attribute sets will be initialized using the curve table specified above.

gga guide 18
GGA employs a custom structure, FGGA_AttributeGroupName, which automatically populates all row names from the curve tables configured in AbilitySystemGlobals, intelligently extracting group name information (the secondary classification enabled by “->” is optional).
Attribute initialization occurs after the application of DefaultAbilitySets, so please ensure that the necessary AttributeSets are configured within DefaultAbilitySets in advance.

Through API

你也可以通过蓝图节点调用如下函数进行初始化。

You can also call the following blueprint nodes to initliaze your ability system component.

gga guide 18

Responding to attribute changes

Through component events

By adding attribute system component to an actor, you can listen to attribute changes and do something about them.

gga guide 20

Among them, Payload contains all the data used in the GameplayEffect execution process.

Inside attribute system component

Besides that, you can also create a new blueprint inheriting from GGA_AttributeSystemComponent and override the HandlePoseGameplayEffectExecute function. As shown in the following figure:

gga guide 21
Bouns: You can also have the attribute change event handled by an external system, as shown in the following example, where I had the attribute change handled by the combat system.
gga guide 21.5

Through AsyncNode.

Usually these asyn blueprint nodes are used to respond to attribute change in UI.

gga guide 22
Whenever possible, avoid updating data on the UI from outside the UI (e.g. Pawn), instead the UI itself gets the relevant information from outside and updates it itself.
A good development practice is: don't let your game logic be tied to specific UI representations.