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!!