Search code examples
unreal-engine4unreal-blueprint

UE4 Blueprint: Cannot get player "death" to replicate on clients, only on server


Unreal Engine 4.22.3 and it is a Listen Server

I feel confident in knowing which blueprints exist where and who owns what. It seems I just cannot wrap my mind about how to make the server replicate something that a client did, so I'd really appreciate some help in understanding this.

In the Player Controller BP I trace under the mouse cursor for other players, when I left-click. If it found a player character, I want to run the "death" event in the Player Character BP. The replication works fine, when it is run by the host, but when a client clicks on another player, the event is only happening client sided. I actually thought it should work, as I set it up.

How would I do this properly? I am pretty sure I must be doing something wrong here.

EDIT: When the client clicks his own character, the player "death" is actually replicated fine. Only when a client clicks a different character than his own, it is not replicated to the server neither to the other clients.

Player Controller BP

Player Character BP


Solution

  • From Replicating Functions in Blueprints:

    There are 3 primary types of replicated functions: Multicast, Run on Server, and Run on owning Client. Multicast functions should be called on the server, where they are executed, and then forwarded automatically to clients. Server functions are called by a client and then only executed on the server. Client functions are called by the server and then only execute on the owning client.

    The PlayerController needs to call a Run on Server function, so that the server's version of that PlayerController can update the authoritative information, which is then sent back to all the clients via a combination of replicated properties and client functions (probably Multicast in this situation).