GAS - What is the best way to send an actor from client to server in a gameplay ability?

I am working on an interaction system for my game. When the client presses a button, they should be able to interact with items, doors, and “interactable” objects within reach.

Currently, when the player overlaps an interactable actor, that actor is added to the player’s interactable actor list. On tick, those actors are sorted by priority, so that when overlapping multiple interactable actors, the best one is chosen for potential interaction.

Now, when I press a button on the local client, I activate an “interact” gameplay ability. In that ability, I want to send the interactable actor that the client deems highest priority to the server, where the server can then verify if the actor is valid and within reach. Then, the server acts on that interactable actor.

I have tried two methods, one where the client calls a server RPC on the player, and another where I send target data populated with the actor to the server. Both seem to work just fine, but I am wondering if either or something else is preferred when using GAS. That’s my main question.

The reason why I don’t simply determine the “highest priority interactable actor” on the server directly instead of on the client and sending it to the server, is for better responsiveness. I believe the client might have a slightly different idea of “highest priority” than the server, especially with latency. If I’m wrong here I would also appreciate some insight.

Thank you!!

You probably already seen this documentation page:

But rather than just a documentation, it’s an actual UE project with examples of simple things. Particularly i’m tested interaction system from this project in a multiplayer game and it worked fine. And yes, this system includes sending interaction actor to server and passing it into corresponding callbacks.

And answering your actual question, my way is to send launch params via TargetData passed along with ActivateAbility. I don’t actually remember if there is a default function like ActivateAbilityWithTargetData, but it’s kinda reasonable to implement thing.
The idea is to implement a way to call ActivateAbility-like function on the client with TargetData attached, pass this call to server via rpc like default ActivateAbility does, forward it to actual TryActivateAbility_Internal… well, i’m not sure i remember the names or process correctly, but you got the idea

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.