The Gameplay Abilities Module
Michael Chapman
(@woppin on Discord)
Gameplay Abilities
Why?
Gameplay Abilities
Resources available:
Concepts
AbilitySystemComponent
AttributeSets
GameplayTags
GameplayEffects
GameplayCues
GameplayAbilities
GameplayTasks
GameplayEvents
Gameplay Abilities : AbilitySystemComponent
Central point for coordinating everything
Attach to any actor implementing IAbilitySystemInterface
AbilitySystem = CreateDefaultSubobject<UAbilitySystemComponent>(TEXT("AbilitySystem"));
On pawns after possession: AbilitySystem->InitAbilityActorInfo(this, this);
Relatively lightweight, attach to anything that should receive effects or activate abilities
Gameplay Abilities : AttributeSets
Store replicated floats wrapped in a struct
UPROPERTY(Category = "Attribute", EditAnywhere, ReplicatedUsing = OnRep_Health, BlueprintReadWrite) FGameplayAttributeData Health;
UFUNCTION() void OnRep_Health() { GAMEPLAYATTRIBUTE_REPNOTIFY(UBaseAttributeSet, Health); } static FGameplayAttribute AttributeHealth();
Account for temporary changes without losing base
AbilitySystem->GetNumericAttribute(UBaseAttributeSet::AttributeHealth());
AbilitySystem->GetNumericAttributeBase(UBaseAttributeSet::AttributeHealth());
Gameplay Abilities : AttributeSets
Attribute Change Events
void PreAttributeBaseChange(const FGameplayAttribute& Attribute, float& NewValue) const;
void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue);
Used to clamp values Eg. health <= max_health
void PostGameplayEffectExecute(const struct FGameplayEffectModCallbackData &Data);
Used to trigger actions as a result of attribute changes, eg health < 0 -> do_ragdoll
bool PreGameplayEffectExecute(struct FGameplayEffectModCallbackData &Data);
Used to modify or discard the values passed into an effect execution.
Gameplay Abilities : GameplayTags
If attributes are the ‘float’ part of describing the game state, tags are the ‘bool’ part. Can be applied locally and have state managed manually:
AbilitySystem->AddMinimalReplicationGameplayTags(InitialTags);
More commonly applied via effects and replicated. Can be applied multiple times and stack.
Triggers events on both client and server
FOnGameplayEffectTagCountChanged& LitheCallback = AbilitySystem->RegisterGameplayTagEvent(FGameplayTag::RequestGameplayTag(UGlobalData::LitheTag), EGameplayTagEventType::AnyCountChange);
LitheCallback.AddUObject(this, &ABaseCharacter::SetLithe);
Gameplay Abilities : GameplayEffects
Predictively applied when done via an ability
Gameplay Abilities : GameplayEffects
Can be applied via an ability, or using the ASC of the target. The latter won’t be predicted
The blueprint nodes for use within abilities omit the middle 3 steps.
Gameplay Abilities : GameplayCues
Cues encapsulate cosmetic effects
Cues hook into several events from the cue manager
Gameplay Abilities : GameplayAbilities
Gameplay Abilities : GameplayAbilities
Gameplay Abilities : GameplayAbilities
Simple ability that applies an effect to the caster
Gameplay Abilities : GameplayAbilities
Simple ability that spawns a projectile.
Gameplay Abilities : GameplayTasks
Gameplay Abilities : GameplayEvents
Acknowledgements