Ejemplo n.º 1
0
    private void CmdSpawnTank()
    {
        // Acquire the spawnPoints object
        mSpawnPoints = GameObject.Find("SpawnPoints").GetComponent <SpawnPoints>();
        // Acquire a spawn position
        Transform spawnPos = mSpawnPoints.GetFreeSpawnPoint();
        // On server so spawn tank for the connected player
        GameObject tank = GameObject.Instantiate(playerTankPrefab);

        // Set the tank's transform to the spawnPos
        tank.transform.position = spawnPos.position;
        tank.transform.rotation = spawnPos.rotation;
        // Then set the player's tank to it
        mTank = tank;

        // Spawn the tank with authority
        NetworkServer.SpawnWithClientAuthority(tank, connectionToClient);
    }