#gameplay-abilities

See also:

Setup

For player controllers and pawns

See Pawns and characters using GAS

Other useful setup

This is optional but can make working with custom abilities etc. a bit simpler.

In DefaultGame.ini you can override UAbilitySystemGlobals with a custom class:

[/Script/GameplayAbilities.AbilitySystemGlobals]
+AbilitySystemGlobalsClassName="/Script/billys.BillysAbilitySystemGlobals"

A custom ability system globals class can create a custom actor info:

FGameplayAbilityActorInfo* UBillysAbilitySystemGlobals::AllocAbilityActorInfo() const
{
	return new FBillysGameplayAbilityActorInfo();
}

The actor info class can provide any kinds of custom fields:

void FBillysGameplayAbilityActorInfo::InitFromActor(AActor* InOwnerActor, AActor* InAvatarActor, UAbilitySystemComponent* InAbilitySystemComponent)
{
	Super::InitFromActor(InOwnerActor, InAvatarActor, InAbilitySystemComponent);
 
	NPCCharacter = Cast<ANPCCharacterBase>(InAvatarActor);
	PlayerCharacter = Cast<ABillysCharacterBase>(InAvatarActor);
}
 
void FBillysGameplayAbilityActorInfo::ClearActorInfo()
{
	Super::ClearActorInfo();
 
	NPCCharacter = nullptr;
	PlayerCharacter = nullptr;
}

A custom ability base class can easily access it like so:

ANPCCharacterBase* UBillysGameplayAbility::GetNPCCharacterFromActorInfo() const
{
	const FBillysGameplayAbilityActorInfo* Info = GetBillysActorInfo(CurrentActorInfo);
	if(!ensure(Info))
	{
		return nullptr;
	}
 
	return Info->NPCCharacter.Get();
}
 
const FBillysGameplayAbilityActorInfo* UBillysGameplayAbility::GetBillysActorInfo(const FGameplayAbilityActorInfo* Info) const
{
	return static_cast<const FBillysGameplayAbilityActorInfo*>(Info);
}