void UGrenadeAbility::ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData)
{
//Activate
//Attach to arm
UE_LOG(LogTemp, Display, TEXT("Activated"));
PCharacter = Cast<ACyberCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(), 0));
if (IsValid(PCharacter))
{
PCharacter->bIsThrowingGrenade = true;
USkeletalMeshComponent* PMesh = PCharacter->GetMesh();
GrenadeObject = GetWorld()->SpawnActor<AGrenadeActorClass>(GrenadeClass);
GrenadeObject->SetOwner(PCharacter);
GrenadeObject->AttachToComponent(PMesh, FAttachmentTransformRules::SnapToTargetNotIncludingScale, FName("WeaponSocket"));
}
//Set variable in player class that character is ready to throw a greande and it will do it when player will release the button!!!
}
void UGrenadeAbility::CancelAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateCancelAbility)
{
//Deactiave
//Detach from arm and give impulse
if (IsValid(PCharacter))
{
PCharacter->bIsThrowingGrenade = false;
UE_LOG(LogTemp, Display, TEXT("Deactiavted"));
}
}
void ACyberCharacter::AbilityActivate()
{
PlayerAbilitySystemComponent->TryActivateAbility(ABOneHandle);
}
void ACyberCharacter::AbilityDeactivte()
{
PlayerAbilitySystemComponent->CancelAbilityHandle(ABOneHandle);
}
void ACyberCharacter::AddAbilityToPlayer()
{
if (AbilityOneClass)
{
ABOneHandle = PlayerAbilitySystemComponent->GiveAbility(FGameplayAbilitySpec(AbilityOneClass, 1, 1));
}
}
Like you see on the screen in link every time i call a Activate Ability function my Deactivate Function calls an one additional time.
This is for sure not any networking or input issue. My project is offline and when i tried to call only DeactiavteAbility within CyberPlayer without a CancelAbility line everything works like intended.