[4.7.6][Bug] "Run on Owning Client" just doesn't work

I am trying to have the server send an RPC to each client that joins the game.

I have setup the following in the playerController:

Here are the replication functions for the function:

44019-run_on_owning_client2.png

…and this is what I get in the log when I have 1 server and 2 clients:

LogBlueprintUserMessages: Server: Authority is granting power

LogBlueprintUserMessages: Server: Got Grant Power Command

LogBlueprintUserMessages: Server: Authority is granting power

LogBlueprintUserMessages: Server: Got Grant Power Command

The RPC never executes on the client (notice all the messages are from the server only).

What am I doing wrong?

You know, I studied this article “[How to Replicate Function in Blueprints][3]” REALLY thoroughly, re-created it, dissected it, put breakpoints everywhere to study it…

From what I can see, it looks like the only reason the client in that tutorial is getting a message at all is because at the very end of the line, you are using variable replication to set the “Inventory” variable – that’s what’s causing the value to be changed, not the function. In fact, it looks like in this tutorial, the “Add Item” is still getting called on the server.

From what I’m seeing, it looks like server-to-client RPCs are not available at all in UE 4.

Is that true?

In PlayerController, only after the GameMode PostLogin event is fired may RPCs be used. Where are you calling the custom event “AssignPowers”? If this is called from Begin Play, the Controller might not be correctly initialized yet. It is then better to create a custom event “Post Login” which will be called by the PostLogin event on a custom GameMode.

The “AssignPowers” is being called after a 2-second delay in my playerCharacter class (behind an authority guard). The controller must be initialized because I can move the player around and see it replicated on other clients in that 2-second window.

I have recently had similar issues and discovered that the replication calls from custom events are only performed if the replication setting of the BP under class defaults is set to ‘Replicates’.

In our project, the player controller is not set to replicate, so I’m going to take a stab in the dark that yours isn’t either. Our solution was to call functions from other BP’s that did replicate, only because we don’t know what problems we might cause by enabling replication on the player controller with a week to go before release.

In the Run On Owning Client tutorial the RPC never executes on the client because the Custom Event is sent from the Level Blueprint. As you can read here, you can only send “Run on server” and “Run on owning client” events from the following actors, or from a component of one of the actors:

  • The client’s PlayerController itself,
  • A Pawn that the client’s PlayerController possesses, or
  • The client’s PlayerState.

Actually, in that tutorial, the Inventory variable is being passed to the client only because it is set as replicated. If you want to make the RPC work, just send the event from one of the actors above, for example the ThirdPersonCharacter Blueprint, otherwise the server won’t know which client to send the event to, and it will only run on the server.

1 Like