Download

Rpc

I have a blueprint that is replicated, a player controller and two pawn(To keep player data) my game is a turn base puzzle RPG.

My problem is that in my main blueprint I can’t manage to call event on the server (it only calls from server to server) and I can’t call multicast event. I have done my research and found stuff that says the client needs to own the object in order to call a RPC on it but I currently have no idea how either I could set so my main blueprint is own by each client, trick the engine by calling it on an object owned by the client(how can I know that ? i have tried on player controller it does not works) or anything I haven’t though of.

I think using the PlayerController is the right approach, like you found from your research. Forgive me the wall of images, but here’s a visual breakdown of the non-owner RPC problem and how you can solve it this way.

Setup: You have a replicated puzzle object that is owned by the server, and some number of other clients.
Problem: Server RPCs can only be called from the owning actor. Since the server owns the puzzle object, there is no way for the replicated puzzle objects to communicate to the server object.

Solution: Clients can route a call to the server through their PlayerController, since they own it.

Here are the functions you would need for an example solution:

PuzzleObject::OnClicked
PuzzleObject::ProcessMove (authority only)
PlayerController::PuzzleClicked
PlayerController::ServerPuzzleClicked (server RPC)

If the click comes from the server, you just do this:
PuzzleObject::OnClicked -> PuzzleObject::ProcessMove

If the click comes from a remote client, you do this:
PuzzleObject::OnClicked -> PlayerController::PuzzleClicked -> PlayerController->ServerPuzzleClicked -> PuzzleObject::ProcessMove

I am a little bit closer I can call server event on player controller but when I want to call the grid function from the server nothing happens unless I am on the server.

My grid events and replication options:

4a24c5d528a43506e72cc189b5bb1945f8807b76.png

My player controller events and replication options:

8eb94b2f7b6c6fe94cd5a630c4378a81f04de8c0.png

The output when called on client and when called on server:

58d0859cff4ab91ba04d4781c19d73bbbdfc3525.png

Replication seems to be a dangerous topic, everything I find is either no answer or a few but never a full answered question. I really don’t know what I am doing wrong.

When calling from the player controller on the server, it seems impossible to call an event on the puzzle object. Is it even possible? do I need two puzzle object one for each client, do I need to call all the heavy validation server stuff on the player controller or even any other idea?

Even if you have no idea, say hello. :slight_smile: I feel lonely in this forum. :frowning:

Is there really no one at all able to answer my question?

Hi 123rockon,

To alleviate some of your confusion, you might want to read through our new documentation on Networking in UE4:

Included in there is a description of the gameplay framework (who can talk to who) and ownership. Benholio’s comment has a useful graph, as well.

Thank you, I will look through all this documentation :).

I tried everything I can think of and read the doc but I still can’t figure this out.