In two videos now Nathan has mentioned that anyone but the original host joining gets two entries in the leader board. My program has not done this. Either with the static string or the updated names strings. It turns out that the remove case kept getting called and taking anyone beyond the inital host off the board. To get things to work for now, i had to comment out the remove case in the HandleLeaderboardEntitiesChanged procedure.
Hi there,
I also did not get the duplicates every time, I think itβs based on a race condition of when that remove case gets called.
By the end of the Leaderboard Names section, this should be resoled anyway, since we add in the check:
if(!entityDisplays.Any(x => x.ClientId == changeEvent.Value.ClientId))
before we spawn new leaderboard entities.
Have you completed this lecture already? Are you still having that issue that the remove code removes the client name?
I had the same issues, did a little debugging and found it was a copy/paste error. Maybe its the same for you. In Leaderboard.cs when we subscribe to the OnPlayerSpawn/Despawn events, I had:
Player.OnPlayerSpawned += HandlePlayerSpawned;
Player.OnPlayerSpawned += HandlePlayerDespawned;
Which resulted in the exact behavior you described β upon joining, the player is immediately added and then immediately removed from the list, and in my case only the host was showing up. The correct code would be:
Player.OnPlayerSpawned += HandlePlayerSpawned;
Player.OnPlayerDespawned += HandlePlayerDespawned;
Hope that helped if you didnt find it already!