Cannot call server RPC from clients
I have a class that does not respond to RPC calls when called from a client. However, there's no problems when called from the server.
I have a Board object in my level (that is, dragged and dropped into the level) that creates a bunch of Piece objects during its
The function I'm attempting to call is located in the board, the pieces being its callers.
The order of actions is as follows:
Output from server:
Output from client:
Things I have tried, to no avail:
asked Jun 13 '15 at 08:08 AM in C++ Programming
answered Nov 14 '15 at 08:23 AM
So the issue ends up being that the object you're calling the function on has no "owner" set since it's just being dropped into the level. If the object has no owner then any network functions wont work. Also, if you set the owner to the server's player controller it will appear as NULL on a client's machine because each client only knows about their own player controller.
The way I was able to get around this is to set the owner to the player controller who is currently interacting with that object. The tricky thing is that you have to call SetOwner ON the server side. Hopefully the steps bellow will explain better.
The following would be a case if a client uses the mouse to select an object in the scene to call a network function on.
Let me know if this is unclear and I can include an actual code sample. I'm just being lazy for now :) Also this might be wrong for future versions of Unreal... this was my hacky solution in 4.8.3.
Also note the behavior of RPC's functions on clients for server owned versions: https://docs.unrealengine.com/latest/CHN/Gameplay/Networking/Actors/RPCs/index.html
answered Dec 06 '15 at 11:46 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here