Search Unity

  1. We have added sub-forums for the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice
  2. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  3. Dismiss Notice

Help Wanted Get Network Object Id from Client Id

Discussion in 'MLAPI' started by mitio31, May 28, 2021.

  1. mitio31

    mitio31

    Joined:
    Apr 17, 2020
    Posts:
    3
    Hello!
    I have a problem, which I do not know how to resolve without rewriting a lot of code.
    So I decided to ask if someone knows how can my problem be resolved without doing that.
    The problem is that I have to store in array or list the network object Ids of all the connected clients.
    When a client disconnects, I want to remove his Id from the array/list. But the problem is that NetworkManager.Singleton.OnClientDisconnectCallback gives you clientId as a parameter. I cannot call NetworkManager.Singleton.ConnectedClients[clientId].PlayerObject, because this object is no longer there (the client disconnected).
    If someone can tell me how can I get the network object ID of the disconnected client I will be really grateful!
    Thanks in advance!
     
  2. luke-unity

    luke-unity

    Unity Technologies

    Joined:
    Sep 30, 2020
    Posts:
    126
    I think the only way to do this currently would be to manually keep track of a id/gameobject dictionary foreach of your player objects and use that to find the player object.
     
unityunity