Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Player Manager

Discussion in 'Multiplayer' started by seanr, Aug 26, 2015.

  1. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    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.
     

    Attached Files:

  2. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    so should something like this be in the UNet HLAPI?
     
    GKiernozek likes this.
  3. SuperNeon

    SuperNeon

    Joined:
    Mar 16, 2014
    Posts:
    85
    It is something we do when we start a project. So yes for me it seems useful to have a player manager in HLAPI.
     
  4. TehGM

    TehGM

    Joined:
    Nov 15, 2013
    Posts:
    89
    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.
     
  5. Firoball

    Firoball

    Joined:
    Aug 6, 2015
    Posts:
    60
    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?
     
  6. Lork

    Lork

    Joined:
    Jul 12, 2013
    Posts:
    79
    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.
     
  7. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    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)
     
    Last edited: Aug 28, 2015
    ckrin likes this.
  8. TehGM

    TehGM

    Joined:
    Nov 15, 2013
    Posts:
    89

    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?
     
  9. LevonRavel

    LevonRavel

    Joined:
    Feb 26, 2014
    Posts:
    179
    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..
     
  10. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    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'.
     
  11. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    What is that? What does it mean? Thanks.
     
  12. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  13. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
  14. ckrin

    ckrin

    Joined:
    Oct 8, 2013
    Posts:
    36
    If i disconnect and reconnect a client, i get dublicates remaining in the list. From my understanding of the code this should not happen.

    Code (CSharp):
    1. public override void OnServerRemovePlayer(NetworkConnection conn, PlayerController player)
    2.     {
    3.         players.RemovePlayer(player.gameObject);
    4.  
    5.         base.OnServerRemovePlayer(conn, player);
    6.     }
    Anyway, would be nice to have in HLAPI !
     
    Last edited: May 3, 2016