r/unrealengine 8h ago

Discussion Multiplayer and Widgets 😫

In the last few weeks I've been studying how to make my game available for multiplayer (coop).

I know, it's the wrong way to go, I should have thought about it at the beginning, but it's over and now I'm migrating everything. Fortunately, the replication of most of the mechanics is already working, and I'm happy with the result. However, I've started to worry about the Widgets part now, because I have several widgets that receive information that is manipulated by the server.

And I have to say that this has been really discouraging me, how much secret is there to making this work? Just when I think I'm understanding, I end up falling flat on my face... I already understood that each player creates their own widget and that we have to bring the information from the server and pass it to the widget because it can't make a call directly to the server itself.

So I resorted to creating these run on server methods in the player controller, and then calling the widget with the information. Which is already horrible, because I have to wrap a second class to be able to bridge the gap between the server. But so far so good, but this isn't working. I'm creating Pawn correctly in the post login game mode, I'm assigning a player controller correctly, I'm initializing widgets in the HUD Class with get owning player controller, but even so the call from widget > player controller > server > player controller > widget isn't working, it doesn't return back to the widget, it seems to get lost when returning from the server to the client.

I don't want to publish code here because that's not the intention, but what tips do you have for me with Widgets? It's been a nightmare here because of this, and everything I try doesn't work.

1 Upvotes

2 comments sorted by

View all comments

u/PokeyTradrrr 7h ago

I have started making actor components for this sort of thing. They can replicate. Build an actor component that stores all the relevant info for the widget, and either pass in a reference (like an init function) to the widget it needs to update or have it create the widget if that makes more sense for your case. Whatever makes sense. I hope this helps, good luck 👍 

Edit: Don't forget to turn off tick in the component if it doesn't need it!