So… here is the problem:
I have dedicated server.
- Server creates actor
- Server gives ability to actor
- Player connects and possesses actor.
- Trying activate ability.
- Getting error:
Warning: Can’t activate LocalOnly or LocalPredicted ability Default__GA_BasicMeleeAtack_C when not local! Net Execution Policy is 0.
and ability doesn’t work.
(btw. dedicated server doesn’t have sessions set up, client connects by IP)
After some digging i found:
if (Ability->GetNetExecutionPolicy() == EGameplayAbilityNetExecutionPolicy::LocalOnly || (Ability->GetNetExecutionPolicy() == EGameplayAbilityNetExecutionPolicy::LocalPredicted && !InPredictionKey.IsValidKey()))
{
// If we have a valid prediction key, the ability was started on the local client so it's okay
ABILITY_LOG(Warning, TEXT("Can't activate LocalOnly or LocalPredicted ability %s when not local! Net Execution Policy is %d. "), *Ability->GetName(), (int32)Ability->GetNetExecutionPolicy());
if (NetworkFailTag.IsValid())
{
InternalTryActivateAbilityFailureTags.AddTag(NetworkFailTag);
NotifyAbilityFailed(Handle, Ability, InternalTryActivateAbilityFailureTags);
}
return false;
}
Net Execution Policy is Local Predicted.
So i think something wrong with PredictionKey… and my skills not enough to find out whats wrong…
Any ideas ???
This is how ability is acquired:
void ACharacterRoot::XAquireAbility(TSubclassOf<UGameplayAbility> wAbilityToAquire)
{
if (AbilitySystemComponentas)
{
if (HasAuthority() && wAbilityToAquire)
{
AbilitySystemComponentas->GiveAbility(FGameplayAbilitySpec(wAbilityToAquire, 1, 0));
}
AbilitySystemComponentas->InitAbilityActorInfo(this, this);
}
}
allso i overridet PossessedBy so after possession informations refreshed:
void ACharacterRoot::PossessedBy(AController * NewController)
{
Super::PossessedBy(NewController);
AbilitySystemComponentas->RefreshAbilityActorInfo();
}