Exemplo n.º 1
0
    void SpawnPlayers(NetworkMessage.Player player)
    {
        if (connectedPlayers.ContainsKey(player.id))
        {
            Debug.Log("Already exists");
            return;
        }

        //Spawn actual game object
        GameObject newPlayerGameObject = Instantiate(playerPrefab);

        //Every players will have different color from the server
        Color newColor = new Color(player.color.R, player.color.G, player.color.B);

        newPlayerGameObject.GetComponent <Renderer>().material.SetColor("_Color", newColor);

        //Add network id
        NetworkCharacter character = newPlayerGameObject.GetComponent <NetworkCharacter>();

        character.SetNetMan(this);
        character.SetNetworkID(player.id);
        character.SetControllable(player.id == ownID);
        connectedPlayers.Add(player.id, newPlayerGameObject);
    }