Player Manager

Show players in the game on all clients using a SyncList.

This will not scale to large numbers of players. This will not work with custom object visibility rules.

2267638–151888–playermanager.zip (34.5 KB)

4 Likes

so should something like this be in the UNet HLAPI?

1 Like

It is something we do when we start a project. So yes for me it seems useful to have a player manager in HLAPI.

I’ll probably use my very own implementation (as I am doing already), but since most game use some kind of player list, I bet many users would appreciate.

I use a simple List for that. But I think nearly everybody needs some sort of management system for the players, so why not have one out of the box?

This seems to be only partially working. When testing out the example scene unchanged, I only see the “Players” HUD on the host, and get “SyncList not initialized” errors in the console.

Yeah, I think it might be a nice addition to have something like this in the HLAPI.

It would be cool to have synchronized player data out of the box and to make it easily accessible on all clients by just passing one simple id (e.g. netId). Something like this maybe:

NetworkManager.GetPlayerObject(id)
or
NetworkManager.Players.GetPlayerName(id)

1 Like

This.
Also, it’d be nice if it’d be possible to send something like HashSet in addition to list. Tbh, it’s not that required, but recently I was working on some API that I wanted to be as fast as possible, and I ended up using HashSet more than the list, lol. It’s faster, after all. And we all want our games to work as fast as possible, eh?

Everyone seems to be overlooking my network package, CrossNet please take a look at my signature with the provided free code at the bottom of the youtube videos. You should be able to create a mysql database to list players if that is inconvenient maybe take a look into scriptable objects…

This is a bug. It has been recognized here: http://forum.unity3d.com/threads/syncliststruct-synclist-not-initialized.335990/

To get rid of the error, just change the class name of ‘PlayerList’ to something that includes the word ‘SyncList’, for example just change it to ‘SyncListPlayers’.

What is that? What does it mean? Thanks.

http://docs.unity3d.com/Manual/UNetVisibility.html

Oh, you meant the Custom Visibility… Thanks.

If i disconnect and reconnect a client, i get dublicates remaining in the list. From my understanding of the code this should not happen.

public override void OnServerRemovePlayer(NetworkConnection conn, PlayerController player)
    {
        players.RemovePlayer(player.gameObject);

        base.OnServerRemovePlayer(conn, player);
    }

Anyway, would be nice to have in HLAPI !