Hello! I get an issue and dont understand why it happens, i have a passive gameplay ability for receiving some gameplay events like incoming exp and etc. But i found, that after some seconds the method
“UAbilityTask_WaitGameplayEvent::WaitGameplayEvent” stopped receiving data, my code for passive ability:
void UPwPassiveAbility::ActivateAbility(const FGameplayAbilitySpecHandle Handle,
const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo,
const FGameplayEventData* TriggerEventData)
{
Super::ActivateAbility(Handle, ActorInfo, ActivationInfo, TriggerEventData);
UAbilityTask_WaitGameplayEvent* GameplayEvent = UAbilityTask_WaitGameplayEvent::WaitGameplayEvent(
OwningAbility, EventTag, OptionalExternalTarget, OnlyTriggerOnce, OnlyMatchExact);
GameplayEvent->EventReceived.AddDynamic(this, &UPwGameplayAbility::OnGameplayEventReceived);
GameplayEvent->Activate();
}
void UPwPassiveAbility::OnGameplayEventReceived(FGameplayEventData Payload)
{
Super::OnGameplayEventReceived(Payload);
if (Payload.EventTag.MatchesTag(FPwGameplayTags::Get().Attributes))
{
const UAbilitySystemComponent* SourceASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(GetAvatarActorFromActorInfo());
const FGameplayEffectSpecHandle EffectSpecHandle = SourceASC->MakeOutgoingSpec(EffectClass, GetAbilityLevel(), SourceASC->MakeEffectContext());
UAbilitySystemBlueprintLibrary::AssignTagSetByCallerMagnitude(EffectSpecHandle, Payload.EventTag, Payload.EventMagnitude);
GetAbilitySystemComponentFromActorInfo()->ApplyGameplayEffectSpecToSelf(*EffectSpecHandle.Data.Get());
}
}
I debugging AbilitySystem inside unreal engine by “showdebug abilitysystem” command, passive ability is active!
Code for sending incoming experience event:
const FPwGameplayTags& GameplayTags = FPwGameplayTags::Get();
FGameplayEventData Payload;
Payload.EventTag = GameplayTags.AttributesMetaIncomingExp;
Payload.EventMagnitude = ExpReward;
UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(Props.SourceCharacter, GameplayTags.AttributesMetaIncomingExp, Payload);
UPDATE: Garbage collector removed ‘GameplayEvent’ object, need to create a member variable and all works as expected now!