FAttributeSetInitter

Helper struct that facilitates initializing attribute set default values from spread sheets ([UCurveTable](API\Runtime\Engine\Engine\UCurveTable)).

Windows
MacOS
Linux

Inheritance Hierarchy

FAttributeSetInitter

FAttributeSetInitterDiscreteLevels

References

Module

GameplayAbilities

Header

/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Public/AttributeSet.h

Include

#include "AttributeSet.h"

Syntax

struct FAttributeSetInitter

Remarks

Helper struct that facilitates initializing attribute set default values from spread sheets (UCurveTable). Projects are free to initialize their attribute sets however they want. This is just want example that is useful in some cases.

Basic idea is to have a spreadsheet in this form: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Default.Health.MaxHealth 100 200 300 400 500 600 700 800 900 999 999 999 999 999 999 999 999 999 999 999 Default.Health.HealthRegenRate 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Default.Health.AttackRating 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 Default.Move.MaxMoveSpeed 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 Hero1.Health.MaxHealth 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 Hero1.Health.HealthRegenRate 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Hero1.Health.AttackRating 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 Hero1.Move.MaxMoveSpeed 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500 500

Where rows are in the form: [GroupName].[AttributeSetName].[Attribute] GroupName - arbitrary name to identify the "group" AttributeSetName - what UAttributeSet the attributes belong to. (Note that this is a simple partial match on the UClass name. "Health" matches "UMyGameHealthSet"). Attribute - the name of the actual attribute property (matches full name).

Columns represent "Level".

FAttributeSetInitter::PreloadAttributeSetData(UCurveTable*) This transforms the CurveTable into a more efficient format to read in at run time. Should be called from UAbilitySystemGlobals for example.

FAttributeSetInitter::InitAttributeSetDefaults(UAbilitySystemComponent* AbilitySystemComponent, FName GroupName, int32 Level) const; This initializes the given AbilitySystemComponent's attribute sets with the specified GroupName and Level. Game code would be expected to call this when spawning a new Actor, or leveling up an actor, etc.

Example Game code usage:

IGameplayAbilitiesModule::Get().GetAbilitySystemGlobals()->GetAttributeSetInitter()->InitAttributeSetDefaults(MyCharacter->AbilitySystemComponent, "Hero1", MyLevel);

Notes: -This lets system designers specify arbitrary values for attributes. They can be based on any formula they want. -Projects with very large level caps may wish to take a simpler "Attributes gained per level" approach. -Anything initialized in this method should not be directly modified by gameplay effects. E.g., if MaxMoveSpeed scales with level, anything else that modifies MaxMoveSpeed should do so with a non-instant GameplayEffect. -"Default" is currently the hardcoded, fallback GroupName. If InitAttributeSetDefaults is called without a valid GroupName, we will fallback to default.

Destructors

Name Description

Public function Virtual

~FAttributeSetInitter()

Functions

Name Description

Public function Const

void

 

ApplyAttributeDefault

(
    UAbilitySystemComponent* Abili...,
    FGameplayAttribute& InAttribute,
    FName GroupName,
    int32 Level
)

Public function Virtual Const

TArray< floa...

 

GetAttributeSetValues

(
    UClass* AttributeSetClass,
    FProperty* AttributeProperty,
    FName GroupName
)

Public function Const

void

 

InitAttributeSetDefaults

(
    UAbilitySystemComponent* Abili...,
    FName GroupName,
    int32 Level,
    bool bInitialInit
)

Public function

void

 

PreloadAttributeSetData

(
    const TArray< UCurveTable* >&...
)

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss