I have a situation that occurs on the very first use of a Gameplay Ability (the UE4 Gameplay Ability System). MY FIRST ABILITY IS REALLY SLOW (like 2-3 secounds of frozen screen lag). Once the first ability fires the rest are fine. This occurs 100% on each launch of the game and never reoccurs until I exit and relaunch.
From the Constructor:
// Abilities and Attributes
PlayerAbilitySystem = CreateDefaultSubobject<UF3CPlayer_AbilitySystemComponent>(TEXT("PlayerAbilitySystem"));
PlayerAbilitySystem->SetIsReplicated(true);
CoreAttributeSet = CreateDefaultSubobject<UCoreAttributeSet>(TEXT("CoreAttributeSet"));
Possessed By Logic has been added:
void AF3CCharacter::PossessedBy(AController * NewController)
{
Super::PossessedBy(NewController);
PlayerAbilitySystem->RefreshAbilityActorInfo();
}
From Begin Play I call an Initialization Routine in my Abiliity Component
void UF3CPlayer_AbilitySystemComponent::InitializeManager(AF3CCharacter* OwningCharacter)
{
// Null check
if (OwningCharacter == nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("No Character passed to Cache. Player_AbilitySystemComponent::InitalizeManager"));
return;
}
if (ActiveAbilities.Num() == 0)
{
UE_LOG(LogTemp, Warning, TEXT("No Items defined in array. Player_AbilitySystemComponent::InitalizeManager"));
return;
}
CharacterCache = OwningCharacter;
Initalized = true;
AbilityWidgets = CharacterCache->HUDWidget->GenerateAbilityWidgets(this, AbilityWidgetTemplate);
// Loop through and grant the abilities and set up the ability bar based on the active abilities array
for (int32 i = 0; i < ActiveAbilities.Num(); i++)
{
// Assign Abilities (Always on the server)
if (CharacterCache->Role == ROLE_Authority)
{
// Not Null check for the ability property
if (ActiveAbilities[i])
{
GiveAbility(FGameplayAbilitySpec(ActiveAbilities[i].GetDefaultObject(), 1, 0));
UE_LOG(LogTemp, Log, TEXT("Player_AbilitySystemComponent: Granted Ability."));
}
}
// Draw the ability buttons
UpdateAbilityDisplay(ActiveAbilities[i]);
}
if (CharacterCache->Role == ROLE_Authority)
InitAbilityActorInfo(OwningCharacter, OwningCharacter);
UE_LOG(LogTemp, Log, TEXT("Player_AbilitySystemComponent: InitializeManager Completed."));
}
I am calling the abilities using the TryActivateAbility from Blueprint.