I recently returned to a project to find one of my abilities in my ability system no longer working for some reason, not sure why as non of the code relating to it was touched.
The direct line of code that this is referring to is this:
void UCRInventoryCombatAbility::ReloadWeapon()
{
if(const UWeaponStaticData* WeaponStaticData = GetEquippedItemWeaponStaticData())
{
if(UInventoryComponent* Inventory = GetInventoryComponent())
{
if(WeaponStaticData->CurrentMagazineSize < WeaponStaticData->MaxMagazineSize && Inventory->GetInventoryTagCount(WeaponStaticData->AmmoTag) > 0)
{
if (UAbilitySystemComponent* AbilityComponent = GetAbilitySystemComponentFromActorInfo())
{
FGameplayEffectContextHandle EffectContext = AbilityComponent->MakeEffectContext();
FGameplayEffectSpecHandle OutSpec = AbilityComponent->MakeOutgoingSpec(UGE_Reload::StaticClass(), 1, EffectContext);
if (OutSpec.IsValid())
{
FGameplayEffectSpec* Spec = OutSpec.Data.Get();
//Spec->DynamicGrantedTags.AddTag(FGameplayTag::RequestGameplayTag(TEXT("State.Reloading")));
Spec->SetDuration(WeaponStaticData->TimeToReloadFinish, true);
ReloadEffectHandle = AbilityComponent->ApplyGameplayEffectSpecToSelf(*Spec);
}
// Start reload animation or logic here
}
Now I have done a bit of research and I created my own game play effect class and set the duration policy to has duration but that still doesn’t seem to be working, am I missing something?
Ok… So your UGE_Reload::StaticClass() is a UGameplayEffect with a duration.
However the error you are getting is in UAbilitySystemComponent::ExecuteGameplayEffect() which means you are trying to execute something. Just above the exact line that is failing there is the following comment:
// Should only ever execute effects that are instant application or periodic application
// Effects with no period and that aren’t instant application should never be executed
Check your stack to see what exactly is calling ExecuteGameplayEffect() since in the snippet you’ve posted only ApplyGameplayEffectSpecToSelf(*Spec) can do it but only if Spec.Def->DurationPolicy == EGameplayEffectDurationType::Instant