Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How is NetworkManager.Singleton.DisconnectClient working?

Discussion in 'Netcode for GameObjects' started by Mj-Kkaya, Apr 6, 2023.

  1. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    193
    Hi,

    I try to disconnect player from NetworkManager via "Host player".
    But this method doesn't give any effect.
    What do I wrong or missed?
    I use just Relay and NetworkManager (NGO).

    Thanks.
     
  2. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    229
    Can you post your code?
     
    Mj-Kkaya likes this.
  3. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    193
    Thank for your answer.
    When u ask my code I saw my mistake.
    I used to kick player "LocalClientId" instead of "clientId".
    Actually When I used HostId to kick player, Unity didn't send any error message.
    There isn't any issue now. :)
     
  4. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    193
    I got new question about NetworkManager.Singleton.DisconnectClient.
    Why OnClientDisconnectCallback doesn't trigger on the Host when Host kicks a player?
    And Kicked player's OnClientDisconnectCallback method's "ulong disconnectedClientId" parameter returns to zero. This is Host playerId, not disconnected playerId. This value should be KickedPlayerId?
     
  5. Sord

    Sord

    Joined:
    Jan 13, 2014
    Posts:
    11
    I have understood that event is like "On-This-ClientDisconnect". If you want observe state of other clients I think good place to look is to relay player prefabs which are spawned and despawned for all existing clients.

    Don't know about your latter question.