Exemple #1
0
    private void OnConnection(int cnnId, int recHostId)
    {
        // Add him to a list
        GameObject playerObject = GetComponent <PlayersManager>().SpawnNewPlayer(cnnId);

        // tell him his Id
        NetClientSpawned message     = new NetClientSpawned();
        PlayerDTO        playerModel = new PlayerDTO();

        playerModel.id   = cnnId;
        playerModel.posX = playerObject.transform.position.x;
        playerModel.posY = playerObject.transform.position.y;
        playerModel.posZ = playerObject.transform.position.z;
        message.Player   = playerModel;
        SendClient(cnnId, recHostId, message, true);

        // broadcast this Id to all others
    }
Exemple #2
0
 private void SpawnClient(NetClientSpawned message)
 {
     Debug.Log(string.Format("Client id: {0}, spawned at position: {1}, {2}, {3}", message.Player.id, message.Player.posX, message.Player.posY, message.Player.posZ));
 }