I’m getting an error returned to me when I’m trying to access a widget in a multiplayer setting. It works fine when the host joins the game but for some reason the value of Announcement Text isn’t being found on the other clients that join the game. Any ideas why?
What does your widget spawning process look like for the missing widget?
Do you have the widget in your HUD BP?
Are you spawning it during your GameMode OnPostLogin event?
If you are running a dedicated server make sure you have the option turned on to create widgets on it if you want to access them on the server (usually not needed)
Well here is your error. You are using get player controller 0
You need to capture the controller during the on post login phase of you game mode, save it as a reference and pass that into your add to viewport.
Get player controller 0 doesn’t work then you start delving into multiplayer. In the case of being inside your controller you could just pass a reference to self (only if its for spawning a widget for that specific player).
Though I would call functions in your HUD via the controller and keep the spawning / de-spawning of widgets there.
Also other players will not have controllers as they will be proxies.
To make sure I understand, the issue is that Get Player Controller 0 is happening too early. I am sort of confused since that node is connected to the Set of the Show Mouse Cursor bool. Does Create Base UI Widget default to Player Controller 0 if there is no value assigned to that pin?
In multiplayer you will have more than player 0 … each new player will be assigned a new index so do not use only zero. (you will be only targeting the 1st player that logged on)
Here would be your game mode ui spawn on player login
Notice you are getting your specific hud from within the controller, casting to your hudbp (can be cached as a variable on begin play to not have to recast) and the needed function is called.
I ended up solving this. After another inspection, I learned that the original code I posted worked. The issue was that a delay needed to happen before the second piece of the code ran. So if anyone finds this in the future, when in doubt add a delay and try. I would also point out that the setup @3dRaven posted is most likely an optimal setup over what I have.