Network Manager playerControllerId always = 0

Hey,

I’m fairly new to multiplayer stuff, so maybe i’m just being dumb. But for some reason when I override OnServerAddPlayer () and log ‘playerControllerId’ it always returns 0.

Any ideas why?

    public override void OnServerAddPlayer (NetworkConnection conn, short playerControllerId)
    {
        Debug.Log ("playerControllerId = " + playerControllerId);

        var spawnPosition = PlayerSpawner.instance.GetSpawnPositionForPlayer (playerControllerId);
        var player = (GameObject)Instantiate (base.playerPrefab, spawnPosition, Quaternion.identity);

        NetworkServer.AddPlayerForConnection (conn, player, playerControllerId);
    }

You may see a ‘player’ as a client + controller, so what’s happening is that your controllers are always the first and only created controllers on those clients :slight_smile:

There is a bit of a description here.

EDIT: So just to clarify, this playerControllerId enables you to have multiple players on a client. For example, 1 computer (client) with 2 gamepads (controllers).