Hey guys,
I have understood how GamePlayAbilities work,
but an only thing is unclear is how to activate them in multiplayer environment? Right now, every time when I try to activate it from Client - I get the crash. As far as I understand, I need to activate it on server, but how?
here is my code:
//GIVE ABILITY ONLY AT SERVER FOR BOTH CLIENTS
**void** ATestCharacter::BeginPlay()
{
Super::BeginPlay();
**if**(AbilitySystem)
{
**if** (HasAuthority() && ThrowAbility)
{
AbilitySystem->GiveAbility(FGameplayAbilitySpec(ThrowAbility.GetDefaultObject(), 1, 0));
}
AbilitySystem->InitAbilityActorInfo(**this**, **this**);
}
}
//when I receive input - I will activate an ability
PlayerInputComponent->BindAction("ThrowItem", IE_Pressed, **this**, &ATestCharacter::Server_Throw);
//THIS CODE WILL CAUSE CRASH ON CLIENT ONLY, ON SERVER ITS OK
**void** ATestCharacter::Server_Throw()
{
**if**(HasAuthority())
{
AbilitySystem -> TryActivateAbilityByClass(ThrowAbility, **true**);
}
}
Why AbilitySystem -> TryActivateAbilityByClass(ThrowAbility, true); is causing crash on clients? what is wrong?