I have the following base-character, base player-controller and ABILITY_SYSTEM_COMPONENT classes.
Abilities and starting effects are not being initialized in the client. It does happen on the server.
So technically, a server has his attributes updated and can activate abilities. But client is unable to have his attributes updated, nor is able to cast any ability.
Base Character:
void AChar::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
ABILITY_SYSTEM_COMPONENT->InitAbilityActorInfo(this, this);
SetOwner(NewController);
// initializing starting abilities and effects
ABILITY_SYSTEM_COMPONENT->initialize_ASC();
}
Player Controller:
// Happens in the client
void Abase_player_controller::AcknowledgePossession(APawn* P)
{
Super::AcknowledgePossession(P);
ACHAR * char_ = Cast<ACHAR>(P);
char_->GetAbilitySystemComponent()->InitAbilityActorInfo(char_, char_);
}
My class - UABILITY_SYSTEM_COMPONENT, sub-classed from UAbilitySystemComponent:
void UABILITY_SYSTEM_COMPONENT::initialize_ASC()
{
if (GetOwnerRole() != ROLE_Authority) return;
initialize_abilities();
initial_effects();
}
void UABILITY_SYSTEM_COMPONENT::initialize_abilities()
{
for (const auto & pair_ : __char->ability_container)
{
if ( !(
pair_.Value &&
pair_.Key.IsValid()
) ) continue;
FGameplayAbilitySpec ability_spec_ = FGameplayAbilitySpec(pair_.Value, 1);
GiveAbility(ability_spec_);
}
b_initial_abilities_provided = true;
}
// __char in an Actor of the class ACHAR that has
// An input-tag - ability class map.
void UABILITY_SYSTEM_COMPONENT::initial_effects()
{
if (!__char) return;
for (const auto & effect_class_ : __char->initial_effect_container)
{
FGameplayEffectContextHandle current_effect_context_handle_;
current_effect_context_handle_.AddSourceObject(this);
FGameplayEffectSpecHandle current_effect_spec_handle_ = MakeOutgoingSpec(
effect_class_,
__char->level,
current_effect_context_handle_
);
ApplyGameplayEffectSpecToSelf(
*current_effect_spec_handle_.Data.Get()
);
}
b_initial_effects_applied = true;
}
// __char also has a TArray of starting effect classes
Interestingly, upon using a breakpoint at the time of button activation of the ability,
in the client, I see that there are absolutely no abilities granted!
Rather the server has abilities granted.
The property - number of activatable abilities, in the ASC shows 11 abilities in Server, but 0 in client!
What is the issue? How to resolve?
And also, should I continue to use GAS or should I build my own inspired by GAS?
Thanks in advance.