Trouble with Multicast Event when checking boolean in PlayerStates

Hi there,

I am developing a mobile multiplayer game. In the game, one player, let’s call them the Leader, is randomly selected. The player selected is shown a list of players currently connected to the server, using UMG widgets, and must select two players to place on a team. After the Leader selects two players, a button appears for them to click which will confirm their selection. Once that button is clicked, I display a new HUD, which contains a ScrollBox, to all players. I then call a Multicast event from the PlayController to create widgets, called ‘PlayerDisplay’, and add them to the ScrollBox. These widgets are just used to display the names of the player’s chosen. All players should see the players the Leader has chosen to then vote to Approve or Decline the team.

Now my problem: All is good until I get to the point where I create the widgets. When the Leader chooses a player on their specific HUD, I cast to that player’s PlayerState and set a boolean variable, ‘PSIsChosenForTeam’, to true. So in my Multicast event where I want to add the PlayerDisplay widgets to the ScrollBox, when I loop through the connected players’ PlayerStates by accessing the PlayerArray in the GameState, I check to see if ‘PSIsChosenForTeam’ is true or not. If it is, I then create the PlayerDisplay widget and add it to the ScrollBox.

Here is that event(This is in the PlayerController):

The problem that occurs is that when I call this event, the widgets are only getting created on the Client that was the Leader(that pressed the confirm button that triggered the event). Now if I delete the Branch that checks if PSIsChosenForTeam is true, the game will successfully create the PlayerDisplay widgets(one for each player in the game) for all players to see. It’s just that I only want the players to be displayed to be the ones that have been selected by the Leader.

Any help would be much appreciated, this problem has been a real pain trying to figure out.

This is how it looks when I remove the Branch node in the event(only problem is that it creates a widget for all players rather than just the ones that were selected):

And here’s how it looks with the Branch node.(Chooses the correct players, but only creates the widget on the Leader’s Client):

So why is having that branch in the event preventing all players from creating the widgets and only working on the Client that called it?

Thanks,

Are you calling the Multicast Event from the server? IIRC, if you call a Multicast event from Client it will only run on that Client itself and wont replicate to others.

It’s in the Player Controller. I have a Run on Server event that loops through all players and displays the new HUD for each player. After the loop is completed, I call the Multicast event.

The Run On Server event is called from the GameHUD widget I have when the player confirms their choice. If you look at the second picture I posted, it shows that the Client was the Leader, so they were the ones that clicked the button in the GameHud, which then casted to the PlayerController and called the Run on Server event. And it successfully created widgets for all players. But that is only achievable if I take out the Branch node in my Multicast event.