Error With Info Updating When Player Joins Lobby

Hello all! I am working on another version of the lobby at the moment but using very very similar code, and am having an error.

Whenever a player starts hosting, you can see “Player 1” and all the other boxes “Waiting for player…” as expected. However, when the second player joins, the host can now see “Player 1” and “Player 2” and the rest “Waiting for player…” but the second player only sees every box as “Waiting for player…” (not even “player 1” which should have been there already)I assume this has something to do with events and the client not being sent the updates for the text, but since I am new to mirror and new to events as well it is hard to track everything back and forth, as I am still figuring out what really does what. And this does not affect starting the game as both players are in the game once started just fine

Thanks for any help!

Hi Mason,

My suggestion is to trace back from how the player names are updated to the events that trigger the update. Put debug.log statements along the way and see where it is getting called or not getting called. This will be a good way to get familiar with the events and what is calling what.

Let me know if you want more help on which methods to look at for this.

Hey there!

I added some Log statements as suggested and best I can tell everything is being invoked properly and seems to be the same for the client or host.(the event is invoked in “ClientHandleDisplayNameUpdated” and “OnStopCLient” in the MyPlayer script and subscribed to in the LobbyMenu script) However I added some more log statements and break points in the actual info update method as shown below:

Using the breaks and logs, I found out that for some reason the client never runs through the first for loop, where the player names should be added, and I also determined that according to the break info, “Players.Count” is 0, so the client has no idea about any other players :thinking: So I am not sure yet. I did check the other way around, and when running as the host the count is immediately one

The Players list it is getting is from the NetworkManager. Did you make any changes to the network manager?

No I don’t believe I made any changes to it. And it works for the host so I don’t see why it wouldn’t work for the client

Can you debug.log(players.Count) and confirm that the client has an empty players list?

I just checked it out, and Players.count outputs 0 for the client

Well as far as I can tell, the Client gets the Players list from the line:
List<MyPlayer> players = ((MyNetworkManager)NetworkManager.singleton).Players;

I can’t figure out why this isn’t working in your project. I suppose you could make a work around to get the players list some other way. I will see if I can understand that line of code and why it might not work.

Also in my version, ClientHandleInfoUpdate() gets called a few times. The first time, the Players list is empty, but then it has a count of 2 the second time. Is yours getting called more than once?

Yeah it Seems weird :thinking: and yes it is getting called twice for me, both 0

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms