Gameplay Ability System - Apply Gameplay Effect To Target not working

I have my Gameplay Ability System component setup on my pawns in a multiplayer scenario. I have an ability that is triggered on left click, the player punches. The punch montage has a animation notify that triggers at the furthest reach of the punch. This will fire off an event to check for overlapping actors in a radius to detect who was punched. It grabs index 0 of the overlapping actors and attempts to call “Apply Gameplay Effect To Target”, using that target’s Target Data. However, the effect never triggers on the target. For testing, I wrapped in a “Apply Gameplay Effect To Owner” and confirmed this WILL apply to the owner. I can’t seem to figure out why the effect doesn’t apply to another target.

Gameplay Ability

Anim Notify

Character BP - Handle getting target

I’m almost certain this was working before. I recently decided to move my GameplayAbilitySystem component to the PlayerState instead of the player character. I then ran into issues where my gameplay events weren’t firing properly, so I moved everything back to the player character.

I am certain the effect isn’t firing because I have code in my attribute set to log when the events fire

void UMyPlayerAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
{
	UE_LOG(LogTemp, Warning, TEXT("PRE"));
	Super::PreAttributeChange(Attribute, NewValue);
}

void UMyPlayerAttributeSet::PostGameplayEffectExecute(const FGameplayEffectModCallbackData& Data)
{
	UE_LOG(LogTemp, Warning, TEXT("POST"));
	Super::PostGameplayEffectExecute(Data);
        // There's other stuff here but I removed it for the sake of this post
}

When my characters load, there are some effects that trigger immediately to initialize their attributes and these work just fine, though they are “ApplyGameplayEffectToSelf” calls.

Any thoughts on what I might look into to determine why my effect isn’t applying on the target? I confirmed my target is valid and it is the character I have actually hit.

I figured out my own issue. I went through the process of setting the GAS up again step by step and realized when I converted my component from being on the player state to being on the character, I forgot to update my InitAbilityActorInfo call. I had

AbilitySystemComponent->InitAbilityActorInfo(MyPlayerState, this);

and I needed

AbilitySystemComponent->InitAbilityActorInfo(this, this);

Hopefully this helps others if they run across this.

5 Likes