Example #1
0
    void uLink_OnPlayerConnected(uLink.NetworkPlayer player)
    {
        string playerName = "Nameless";

        if (player.loginData != null)
        {
            player.loginData.TryRead(out playerName);
        }

        if (uLink.NetworkView.FindByOwner(player).Length > 0)
        {
            return;
        }

        Color playerColor = HSVToRGB(UnityEngine.Random.Range(0.0f, 360.0f), 0.3f, 1);

        GameObject[] spawns     = GameObject.FindGameObjectsWithTag(SpawnTag);
        int          spawnindex = UnityEngine.Random.Range(0, spawns.Length - 1);
        Transform    spawn      = spawns[spawnindex].transform;

        uLink.Network.Instantiate(player, proxyPrefab, ownerPrefab, creatorPrefab, spawn.position, spawn.rotation, 0, playerColor, playerName);

        chat.Chat(playerName + " has joined", playerColor);
    }