SendGameplayEventToActor Replication

I am looking to add replication to the game that I’m working on. However, one thing I’ve noticed is that “SendGameplayEventToActor” has stopped working. The ability it’s activating is replicated and locally predicted.

Does the function that calls SendGameplayEventToActor need to be replicated? If so, does it need to be client, server, or netmulticast? I have tried all three but none of them seem to make the ability actually trigger.

It all worked fine before I started working on replication. This is where I can trace the failure to… I know they have access to the ability I’m trying to execute. From what I can see on breakpoints all of the variables are set and whatnot.

Here’s the function inside the CPP file:



void AMonster::ExecuteMonMove_Implementation(int MonMoveNum)
{
   FGameplayEventData Payload;
   FGameplayTag Tag;
   Payload.Instigator = this;
   Payload.Target = this;

   if (AbilitySystem)
   {
      switch (MonMoveNum)
      {
         case 1:
            Tag = FGameplayTag::RequestGameplayTag(this->GetAbility1Tag());
            Payload.EventTag = Tag;
            UE_LOG(LogTemp, Warning, TEXT("%s"), *Tag.ToString())
            UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(this, Tag, Payload);
            break;
         // There are more cases, I just shortened it.
        }
   }
}


And here’s the header declaration:



UFUNCTION(BlueprintCallable, reliable, Server, WithValidation)
        void ExecuteMonMove(int MonMoveNum);


Hi @ProjectTallGrass.

Does AMonster implement AbilitySystemInterface ?
Does AMonster have an AbilitySystemComponent ?

These are two requirements for the SendGameplayEventToActor function to do anything.

I would also suggest you look at this docummentation.

Good luck bud!

Hey @JeFrYx,

Unfortunately AMonster does implement AbilitySystemInterface, and it has an AbilitySystemComponent. All of this seemed to work, prior to setting up multiplayer/replication.

The odd thing is, the AI versions of AMonster are able to execute that same function above through their Behavior Trees and it activates the ability just fine.

The situation when it doesn’t work, is when I try and execute it through my player controller after receiving input. Do you happen to know anything else I can check? Does it have something to do with the UFUNCTION declarations possibly?

Thanks!

I happened upon this thread after having pretty much the same problem. I’ve solved it for at least my use case and figured I’d post some info on my particular solution should it help someone else down the road…

I have a gameplay ability activated by UI. The ability is a locally predicted one that requires target actor data. Immediately upon activation I’m sending the ability a gameplay event with configuration data.

Pre-multiplayer, I was just calling UAbilitySystemBlueprintLibrary::SendGameplayEventToActor directly from my UI - which works in the following scenarios:

  • standalone (no multiplayer)
  • listen server, done from the listen server
  • client

However, in the last scenario, it won’t execute on the server. You do indeed need to RPC this call properly to the server while keeping intact your call on the client. For me, I just created a generic “Proxy_SendGameplayEventToActor” function on my player controller which takes the exact same signature of SendGameplayEventToActor. It’s nothing special (no RPC on this function). For me, I did decide to make it a UFUNCTION(BlueprintCallable) for potential future use. This function is defined as such:



void ATopDownController::Proxy_SendGameplayEventToActor(AActor* TargetActor, FGameplayTag Tag, FGameplayEventData EventData)
{
  if (!HasAuthority())
  {
    Server_Proxy_SendGameplayEventToActor(TargetActor, Tag, EventData);
  }
  UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(TargetActor, Tag, EventData);
}


Server_Proxy_SendGameplayEventToActor just makes the same call to SendGameplayEventToActor. It’s declared as such:



protected:
  UFUNCTION(Server, Reliable, WithValidation)
  void Server_Proxy_SendGameplayEventToActor(AActor* TargetActor, FGameplayTag Tag, FGameplayEventData EventData);


Doing this definitely works on both the server & the client.

Kind of an old topic but still a thing, thank you for posting your fixed, it helped me fix my desync issue on clients