UnityEngine.Networking.NetworkConnection.RemovePlayerController C# (CSharp) Method

RemovePlayerController() private method

private RemovePlayerController ( short playerControllerId ) : void
playerControllerId short
return void
        internal void RemovePlayerController(short playerControllerId)
        {
            for (int i = this.m_PlayerControllers.Count; i >= 0; i--)
            {
                if ((playerControllerId == i) && (playerControllerId == this.m_PlayerControllers[i].playerControllerId))
                {
                    this.m_PlayerControllers[i] = new PlayerController();
                    return;
                }
            }
            if (LogFilter.logError)
            {
                Debug.LogError("RemovePlayer player at playerControllerId " + playerControllerId + " not found");
            }
        }

Usage Example

        public static bool RemovePlayer(short playerControllerId)
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("ClientScene::RemovePlayer() for ID " + playerControllerId + " called with connection [" + s_ReadyConnection + "]");
            }

            PlayerController playerController;

            if (s_ReadyConnection.GetPlayerController(playerControllerId, out playerController))
            {
                var msg = new RemovePlayerMessage();
                msg.playerControllerId = playerControllerId;
                s_ReadyConnection.Send(MsgType.RemovePlayer, msg);

                s_ReadyConnection.RemovePlayerController(playerControllerId);
                s_LocalPlayers[playerControllerId] = new PlayerController();

                Object.Destroy(playerController.gameObject);
                return(true);
            }
            if (LogFilter.logError)
            {
                Debug.LogError("Failed to find player ID " + playerControllerId);
            }
            return(false);
        }