The set up for AbilityTasks is mostly same as Gameplay Tasks
- Create static “factory” function
- Override
Activate
UKotAbilityTask_WaitForOverlap* UKotAbilityTask_WaitForOverlap::KotWaitForOverlap(UGameplayAbility* OwningAbility)
{
auto* Task = NewAbilityTask<UKotAbilityTask_WaitForOverlap>(OwningAbility);
return Task;
}
void UKotAbilityTask_WaitForOverlap::Activate()
{
SetWaitingOnAvatar();
if (UPrimitiveComponent* PrimComponent = GetComponent())
{
PrimComponent->OnComponentBeginOverlap.AddDynamic(this, &ThisClass::BeginOverlap);
}
}
//etc.
Handling delegates
- If you bind any Delegates in the ability task you can override
OnDestroy
for cleaning them up. - Before you broadcast any delegates from the ability task, check
ShouldBroadcastAbilityTaskDelegates()