tranek / GASDocumentation

My understanding of Unreal Engine 5's GameplayAbilitySystem plugin with a simple multiplayer sample project.
MIT License
4.27k stars 789 forks source link

Applying a Gameplay Effect Spec with Source/Target Tags Requirements in C++ inside Gameplay Ability Class #56

Closed lucoiso closed 3 years ago

lucoiso commented 3 years ago

I'm trying to cast a gameplay effect on a character with a gameplay effect spec to use the tag requirements and manage the modifiers that will be used. But I'm confused because my test character has all the requirement tags, but the effect doesn't apply and i'm going crazy trying to figure out where i'm failing.

void UGASGameplayAbility::ApplyEffectToSelf()
{
     for (const auto& _Effect : AbilityEffects)
     {
         GetCurrentAbilitySpec()->SetByCallerTagMagnitudes.Add(_Effect.Key, AbilityActiveTime);
         auto _SpecHandle = MakeOutgoingGameplayEffectSpec(GetCurrentAbilitySpecHandle(), GetCurrentActorInfo(), GetCurrentActivationInfo(), _Effect.Value.Get());

         if (_SpecHandle.IsValid())
         {
             ApplyAbilityTagsToGameplayEffectSpec(*_SpecHandle.Data.Get(), GetCurrentAbilitySpec());
             ApplyGameplayEffectSpecToOwner(GetCurrentAbilitySpecHandle(), GetCurrentActorInfo(), GetCurrentActivationInfo(), _SpecHandle);
         }
     }
 }

ue5pebug

ameaninglessname commented 3 years ago

Why not just step into ApplyGameplayEffectSpecToOwner and look what happened?

lucoiso commented 3 years ago

Why not just step into ApplyGameplayEffectSpecToOwner and look what happened?

I did this but didn't figure out what it could be, the effect acts as if it was applied normally, but modifiers that have requirements are blocked as if they don't have the necessary tags.

I tried other ways to apply what I want, but I was unsuccessful. The tags are being applied correctly to Gameplay Spec, I checked using GetActorTags() and GetSpecTags(), but the effect is not applied. When removing requirement tags from modifiers in the Gameplay Effect, the effect is applied normally.

The same happens when changing the application and tags from Source to Target.

I'm taking ideas on how I can better visualize what might be happening or examples of how to apply the effect with requirements. :S

lucoiso commented 3 years ago

As the problem has more to do with the plugin and not the GAS-Documentation, I closed the thread and transferred my question to the AnswerHub and Unreal Forum. :)