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.
This is the error message I got
Assertion failed: (Spec.GetDuration() == UGameplayEffect::INSTANT_APPLICATION || Spec.GetPeriod() != UGameplayEffect::NO_PERIOD) [File:D:\build++UE5\Sync\Engine\Plugins\Runtime\GameplayAbilities\Source\GameplayAbilities\Private\AbilitySystemComponent.cpp] [Line: 1007]
UnrealEditor_GameplayAbilities
UnrealEditor_GameplayAbilities
UnrealEditor_NameOfGame!UCRInventoryCombatAbility::ReloadWeapon() [D:\UnrealProjects\NameOfGame\Source\NameOfGame\World\PlayerCharacter\Player\AbilitySystem\Abilities\CRInventoryCombatAbility.cpp:81]
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?