What are some meaningful use cases for Client RPCs?

I am having a bit of a hard time to see the benefit of having a client RPC. Cosmetic actions on the client side for example could simply be triggered on the client itself, for example with the trigger box we created in one of the last sessions.

There could be things like warning messages for all clients maybe which could be a reason for a client RPC, but I’d like to have a few more things just get a better grasp of it :slight_smile:

Here’s a scenario I can think of. Player X and player Y are in a building, but not on the same floor. X opens a door. UE sends a RPC to the server to find out if the door can be opened, it gets opened, a sound is played for X, etc. That should all be pretty straightforward.

But if Y is within earshot, or what’s called Network Relevant, then Y should hear the door open. A server can send a client RPC to play the sound to all players who are Network Relevant. That would include X and Y.

You could just wait for a property to replicate, but that can be delayed. So X may hear the door open as they open it. And a moment later, Y hears it. Calling the RPC makes it instant.

Cosmetic triggers may be triggered by server events and honestly, all client displayed events should be triggered from the server as the server is the only source of truth in a game. This is the only way to ensure that these events are triggered appropriately and not as a result of cheating.

Now you might argue that cosmetic effects don’t matter but they could result in obfuscation of the level and as such give another player the advantage.

Of course these things may not be just cosmetic and could result in player death for example. So, the origin of anything should always be the server.

Thank you for the example :+1:t4:

Regarding the delayed proprty replication: Where can I get more info about this? How long is this delay? Does it happen every time? Why is it delayed and rpc not? Etc. Etc. :smiley:

The delay has many factors but one key factor is latency. If you were in Europe and connecting to the US, there might be a. 5 second delay, to Australia more like 1.5 seconds. Same network would or should be instantaneous. This is often why game companies employ regional servers. A couple of seconds delay for a website is nothing but for a game this is critical.

Of course, that’s not the only factor but important one. Other factors are differing frame rates between clients, another would be congestion at the ISP level.

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

Privacy & Terms