66#include " EnhancedInputComponent.h"
77#include " GAS_Example/Characters/CharacterBase.h"
88
9+ #define LOCTEXT_NAMESPACE " GameplayAbility"
910
1011UCustomGameplayAbility::UCustomGameplayAbility ()
1112{
@@ -119,15 +120,21 @@ void UCustomGameplayAbility::HandleInputPressedEvent(const FGameplayAbilityActor
119120return ;
120121}
121122
123+ if (!Spec->GetPrimaryInstance (),
124+ TEXT (" %hs called on the CDO. NonInstanced abilities are deprecated, thus we always expect this to be called on an instanced object." ), __func__)
125+ {
126+ return ;
127+ }
128+
122129if (Spec->Ability ->bReplicateInputDirectly && !AbilitySystemComponent->IsOwnerActorAuthoritative ())
123130{
124- AbilitySystemComponent->ServerSetInputPressed (Spec->Ability . Get ()->GetCurrentAbilitySpecHandle ());
131+ AbilitySystemComponent->ServerSetInputPressed (Spec->GetPrimaryInstance ()->GetCurrentAbilitySpecHandle ());
125132}
126133
127134AbilitySystemComponent->AbilitySpecInputPressed (*Spec);
128135
129136// Invoke the InputPressed event. This is not replicated here. If someone is listening, they may replicate the InputPressed event to the server.
130- AbilitySystemComponent->InvokeReplicatedEvent (EAbilityGenericReplicatedEvent::InputPressed, Spec->Handle , Spec->ActivationInfo .GetActivationPredictionKey ());
137+ AbilitySystemComponent->InvokeReplicatedEvent (EAbilityGenericReplicatedEvent::InputPressed, Spec->Handle , Spec->GetPrimaryInstance ()-> GetCurrentActivationInfo () .GetActivationPredictionKey ());
131138}
132139
133140void UCustomGameplayAbility::HandleInputReleasedEvent (const FGameplayAbilityActorInfo* ActorInfo,const FGameplayAbilitySpecHandle SpecHandle)
@@ -182,3 +189,4 @@ void UCustomGameplayAbility::K0_OnRemoveAbility_Implementation(const FGameplayAb
182189{
183190K0_OnRemoveAbility (ActorInfo, Spec);
184191}
192+ #undef LOCTEXT_NAMESPACE