I’ve been struggling with a really troublesome design problem in various forms for the last 2-3 months, in that accessing server-side data via UMG is a huge pain/basically impossible.
I’m trying to access variables from the Game Mode via a UMG. This works 100% fine on the single-player, listen server (with authority). With clients however, accessing this data becomes a design struggle.
With UMG, it seems that clients cannot access ANY server-side data, such as Game Mode, Game State, Player State, etc. The only way I can think of so far is to duplicate every needed variable into the Character/Pawn owning the UMG widget and update it constantly (which is horribly inefficient).
Am I doing something seriously wrong with how I spawn widgets for clients? Is there a special way to communicate with server-side data or something I’ve missed altogether? Or is this just design (would Player List’s and game data not be stored in Gamemode/Gamestate?)
TLDR; What is the proper/best way to access server-side data in UMG for multiplayer clients?
Yes. You are doing something seriously wrong. ������
Gamemode does not exist at all on the client. Only on the server. Gamemode never replicates. You should use GameState for the things you want to replicate to the clients.
I looked into GameState, and moved everything to there (all the game-data), set the variables to replicate and it works properly. I didnt realise it was a combination of both GameState and setting server-side variables to replicate as well (thought that things like the GameMode/GameState would always replicate their variables, stupid mistake. Lots of lag (almost a second) on the clients accessing the casted PlayerState variables for some reason, but it does all work. Looks like I will have to have a somewhat large GameState singleton…
Only issue I am having is that using ‘Join Session’ doesn’t seem to work when you build the blueprints via ‘Nativise Assets’ (convert them to C++). Might start a different thread about that.