Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    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:
    162
    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:
    223
    Can you post your code?
     
    Mj-Kkaya likes this.
  3. Mj-Kkaya

    Mj-Kkaya

    Joined:
    Oct 10, 2017
    Posts:
    162
    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:
    162
    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:
    10
    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.