예제 #1
0
    void SpawnPlayer()
    {
        Debug.Log("Player spawned.");

        Vector3 pos = new Vector3(UnityEngine.Random.Range(-2.0f, 2.0f), 0.0f, 0.0f);

        playerGO            = Instantiate(PlayerPrefab, pos, new Quaternion());
        playerInfo          = playerGO.GetComponent <NetInfo>();
        playerInfo.localID  = m_Connection.InternalId.ToString();
        playerInfo.playerID = PlayerID;
        playerInfo.ActivateCam();
        playerGO.AddComponent <PlayerControl>();
        AllPlayersGO.Add(playerGO);

        //// Example to send a handshake message:
        PlayerSpawnMsg m = new PlayerSpawnMsg();

        m.Position = pos;
        m.ID       = PlayerID;
        SendToServer(JsonUtility.ToJson(m));
    }