I’m having a hell of a time doing something as simple as removing a UMG User Widget from the viewport for all connected players when the Server clicks a button. I’m also having a lot of trouble having players access stuff in their HUD via replication.
I’ve set up a simple debug “lobby” menu that is created on all players by the server on PostLogin (game mode) as soon as they connect. This is how the menu is created. The Create Main Menu Widget function is triggered by a RepNotify of a variable (team) I change in each player controller as they connect.
This works fine. In my lobby menu, the clients only see a message telling them to wait for the host. The host/server has a Start Game button, which calls a Multicast function in the Controller:
The Multicast event in the controller then does this:
This succeeds in removing the menu from the client as well as the server, but only if the event is Reliable. If it’s not Reliable, the Event is never even called on the Client. Why don’t I just make it reliable? Because of this bug: https://answers.unrealengine.com/questions/97569/client-cant-join-a-server-if-server-is-running-rel.html
Now my questions:
In the above screenshot, the cast to GameHUD only succeeds on the client if I have a Get Player Controller (the highlighted box) in front of Get HUD. Why do I need to get the controller, while in the controller? Does a self reference in a Multicasted event actually refer to the controller that triggered the event (the server’s) and not the controller it’s being executed in (the local controllers of all the clients).
Why does the event not fire at all on the Clients if it’s not Reliable? It NEVER fires, it’s not like it sometimes doesn’t. Maybe I don’t completely understand what Reliability means in Unreal, but I would not expect events to get dropped when there is literally nothing else going on and we’re on a LAN.
When I originally tried to do this, I tried removing the lobby menu using an event in my HUD class, since that’s where its spawned and stored as a variable. I put this directly in the UMG widget on the OnClicked event as seen below. Unfortunately, this only ended up working on the server. The client never executes the multicast (and reliable) event in GameHUD. Why is this? How does replication work when it comes to the HUD?
I understand I should ideally be using BP Interfaces to have my UI do stuff to my other Blueprints, but Interface functions are not replicated and there is no option anywhere to make them replicate, even though the documentation says there is.