Multiplayer - Server request client HUD to run function

Working on my multiplayer game (dedicated server), and I ran into some confusion regarding updating my client’s HUD from server.

Scenario:

  • I have a buff/debuff system which is all handled server-side, which works perfectly. However, I want to display these buffs to the affected client.
  • When the buff is created and attached to the player, I want the server to call a function from a widget blueprint on the client side.
  • However, I run into the error message that the HUD reference is not found because it doesn’t exist in the server’s eyes.

How can I call a HUD widget function from a server-only chain of events?
139228-139226-

The HUD class isn’t replicated so only the client who owns that HUD knows of it. This means that if the server side tries to reference something on the client that only the client owns, it will not work.

What you can do is send the data you want to change to a class that is replicated, such as the PlayerController, which is only owned by the server and the owning client; clients can only see their own PlayerController class. The PlayerController is also in charge of creating the client side HUD class so it has a reference. You can use this reference to pass in anything from the PlayerController to the HUD.

To fix my issue, I created a client-only function back in PlayerController that was able to update the HUD as mentioned.
The server told the owning PlayerController to update their HUD within the chain of command.